Class: Bunto::Tags::Link
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Bunto::Tags::Link
- Defined in:
- lib/bunto/tags/link.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tag_name, relative_path, tokens) ⇒ Link
constructor
A new instance of Link.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, relative_path, tokens) ⇒ Link
Returns a new instance of Link.
10 11 12 13 14 |
# File 'lib/bunto/tags/link.rb', line 10 def initialize(tag_name, relative_path, tokens) super @relative_path = relative_path.strip end |
Class Method Details
.tag_name ⇒ Object
5 6 7 |
# File 'lib/bunto/tags/link.rb', line 5 def tag_name self.name.split("::").last.downcase end |
Instance Method Details
#render(context) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bunto/tags/link.rb', line 16 def render(context) site = context.registers[:site] site.each_site_file do |item| return item.url if item.relative_path == @relative_path # This takes care of the case for static files that have a leading / return item.url if item.relative_path == "/#{@relative_path}" end raise ArgumentError, <<eos Could not find document '#{@relative_path}' in tag '#{self.class.tag_name}'. Make sure the document exists and the path is correct. eos end |