Class: Jekyll::Authors::TagUrlTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::Authors::TagUrlTag
- Defined in:
- lib/jekyll-authors/tags.rb
Overview
Returns a correctly formatted tag url based on site configuration.
Use without arguments to return the url of the tag list page.
{% tag_url %}
Use with argument to return the url of a specific catogory page. The argument can be either a string or a variable in the current context.
{% tag_url tag_name %}
{% tag_url tag_var %}
Instance Method Summary collapse
-
#initialize(tag_name, text, tokens) ⇒ TagUrlTag
constructor
A new instance of TagUrlTag.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, text, tokens) ⇒ TagUrlTag
Returns a new instance of TagUrlTag.
105 106 107 108 |
# File 'lib/jekyll-authors/tags.rb', line 105 def initialize(tag_name, text, tokens) super @tag = text end |
Instance Method Details
#render(context) ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/jekyll-authors/tags.rb', line 110 def render(context) base_url = context.registers[:site].config['base-url'] || '/' tag_dir = context.registers[:site].config['tag_dir'] || 'tags' tag = context[@tag] || @tag.strip.tr(' ', '-').downcase tag.empty? ? "#{base_url}#{tag_dir}" : "#{base_url}#{tag_dir}/#{tag}" end |