Class: Glim::LiquidTags::PostURL

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/liquid_ext.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, options) ⇒ PostURL

Returns a new instance of PostURL.



138
139
140
141
# File 'lib/liquid_ext.rb', line 138

def initialize(tag_name, markup, options)
  super
  @post_name = markup.strip
end

Instance Method Details

#render(context) ⇒ Object



143
144
145
146
147
148
149
# File 'lib/liquid_ext.rb', line 143

def render(context)
  if file = Jekyll.sites.last.post_links[@post_name]
    file.url
  else
    raise Glim::Error.new("post_url: No post found for: #{@post_name}")
  end
end