Class: Jekyll::Tags::PostUrl
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::Tags::PostUrl
- Includes:
- Filters::URLFilters
- Defined in:
- lib/jekyll/tags/post_url.rb
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens) ⇒ PostUrl
constructor
A new instance of PostUrl.
- #render(context) ⇒ Object
Methods included from Filters::URLFilters
#absolute_url, #relative_url, #strip_index
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ PostUrl
Returns a new instance of PostUrl.
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jekyll/tags/post_url.rb', line 66 def initialize(tag_name, markup, tokens) super @markup = markup.strip @template = Liquid::Template.parse(@markup) if @markup.include?("{{") # Deprecated instance_variables. # To be removed in Jekyll v5.0. @orig_post = @markup @post = nil end |
Instance Method Details
#render(context) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/jekyll/tags/post_url.rb', line 77 def render(context) @context = context @resolved_markup = @template&.render(@context) || @markup site = context.registers[:site] begin @post_comparer = PostComparer.new(@resolved_markup) rescue StandardError raise_markup_parse_error end # For backwards compatibility only; deprecated instance_variable. # To be removed in Jekyll v5.0. @post = @post_comparer # First pass-through. site.posts.docs.each do |post| return relative_url(post) if @post_comparer == post end # First pass-through did not yield the requested post. Search again using legacy matching # method. Log deprecation warning if a post is detected via this round. site.posts.docs.each do |post| next unless @post_comparer.deprecated_equality(post) log_legacy_usage_deprecation return relative_url(post) end raise_post_not_found_error end |