Sha256: 0bae2d33a4048f1919dc21ca0ce637accc9d3b3db11b0115cf835ddc24d65070
Contents?: true
Size: 1.22 KB
Versions: 4
Compression:
Stored size: 1.22 KB
Contents
module Jekyll module LanguagePlugin module Tags class LanguageTag < Liquid::Tag def initialize(tag_name, markup, tokens) super @markup = markup end def render(context) p = Liquid::Parser.new(@markup) name = Liquid::Expression.parse(exp = p.expression) key = context.evaluate(name) raise Liquid::SyntaxError.new("Invalid language key expression: #{exp}") if key.nil? # get language string from evaluated key str = Jekyll::LanguagePlugin::LiquidContext.get_language_string(context, key) if p.consume?(:colon) loop do arg = Liquid::Expression.parse(exp = p.expression) argstr = context.evaluate(arg) raise Liquid::SyntaxError.new("Invalid parameter expression: #{exp}") if argstr.nil? raise Jekyll::LanguagePlugin::PluginError.new("Language string is lacking parameter placeholder.") unless str.include?("%%") str.sub!("%%", argstr) break if !p.consume?(:comma) end end str end end end end end Liquid::Template.register_tag('t', Jekyll::LanguagePlugin::Tags::LanguageTag)
Version data entries
4 entries across 4 versions & 1 rubygems