class JekyllIndexPages::URLTag
Constants
- STRING_SYNTAX
- VARIABLE_SYNTAX
Public Class Methods
new(tag_name, markup, tokens)
click to toggle source
Calls superclass method
# File lib/jekyll-index-pages/tags.rb, line 6 def initialize(tag_name, markup, tokens) super @markup = markup.strip @tag_name = tag_name end
Public Instance Methods
filter_config(config)
click to toggle source
# File lib/jekyll-index-pages/tags.rb, line 40 def filter_config(config) nil end
has_kind?(site, kind)
click to toggle source
# File lib/jekyll-index-pages/tags.rb, line 36 def has_kind?(site, kind) false end
parse_params(context)
click to toggle source
# File lib/jekyll-index-pages/tags.rb, line 12 def parse_params(context) input = "" if @markup.match(STRING_SYNTAX) input = @markup.gsub("\"", "") elsif @markup.match(VARIABLE_SYNTAX) input = Liquid::Variable.new(@markup).render(context) else raise ArgumentError, <<-eos Invalid syntax for #{@tag_name} tag: #{@markup} Valid syntax: {% #{@tag_name} "Name" %} or {% #{@tag_name} variable %} eos end end
render(context)
click to toggle source
# File lib/jekyll-index-pages/tags.rb, line 44 def render(context) site = context.registers[:site] master_config = site.config["index_pages"] || {} kind = parse_params(context) return "" if !has_kind?(site, kind) slug = I18n.transliterate( Jekyll::Utils.slugify(kind), :locale => I18n.locale ) config = filter_config(master_config) permalink = config ? config["permalink"] : "/:label/" permalink.sub(":label", slug) end