Class: Jekyll::Tags::PostUrl

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll/tags/post_url.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, post, tokens) ⇒ PostUrl

Returns a new instance of PostUrl.



38
39
40
41
42
# File 'lib/jekyll/tags/post_url.rb', line 38

def initialize(tag_name, post, tokens)
  super
  @orig_post = post.strip
  @post = PostComparer.new(@orig_post)
end

Instance Method Details

#render(context) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/jekyll/tags/post_url.rb', line 44

def render(context)
  site = context.registers[:site]

  site.posts.each do |p|
    if @post == p
      return p.url
    end
  end

  raise ArgumentError.new <<-eos
Could not find post "#{@orig_post}" in tag 'post_url'.

Make sure the post exists and the name is correct.
eos
end