Class: Moft::Tags::PostUrl

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

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, post, tokens) ⇒ PostUrl

Returns a new instance of PostUrl.



23
24
25
26
27
# File 'lib/moft/tags/post_url.rb', line 23

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

Instance Method Details

#render(context) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/moft/tags/post_url.rb', line 29

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

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

  puts "ERROR: post_url: \"#{@orig_post}\" could not be found"

  return "#"
end