Class: Octopress::Printable::Tags
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Octopress::Printable::Tags
- Defined in:
- lib/octopress-printable/tags.rb
Instance Method Summary collapse
-
#initialize(tag_name, post, tokens) ⇒ Tags
constructor
A new instance of Tags.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, post, tokens) ⇒ Tags
Returns a new instance of Tags.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/octopress-printable/tags.rb', line 52 def initialize(tag_name, post, tokens) super @orig_post = post.strip begin @post = PostLinkComparer.new(@orig_post) rescue raise ArgumentError.new "Could not parse name of post \"\#{@orig_post}\" in tag 'post_link'.\nMake sure the post exists and the name and date is correct.\n" end end |
Instance Method Details
#render(context) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/octopress-printable/tags.rb', line 65 def render(context) site = context.registers[:site] site.posts.each do |p| if @post == p return "<a href=\"#{ p.url }\">#{ @post.text ? @post.text.strip! : p.title }</a>" end end raise ArgumentError.new "Could not find post \"\#{@orig_post}\" in tag 'post_link'.\nMake sure the post exists and the name and date is correct.\n" end |