Class: Jekyll::Polyglot::Liquid::StaticHrefTag

Inherits:
Liquid Liquid::Block
  • Object
show all
Defined in:
lib/jekyll/polyglot/liquid/tags/static_href.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, params, tokens) ⇒ StaticHrefTag

Returns a new instance of StaticHrefTag.



5
6
7
# File 'lib/jekyll/polyglot/liquid/tags/static_href.rb', line 5

def initialize(tag_name, params, tokens)
  super
end

Instance Method Details

#render(context) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/jekyll/polyglot/liquid/tags/static_href.rb', line 9

def render(context)
  text = super
  href_attrs = text.strip.split '='
  valid = (href_attrs.length == 2 && href_attrs[0] == 'href') && href_attrs[1].start_with?('"') && href_attrs[1].end_with?('"')
  unless valid
    raise Liquid::SyntaxError, "static_href parameters must include match href=\"...\" attribute param, eg. href=\"http://example.com\, href=\"/about\", href=\"/\" , instead got:\n#{text}"
  end

  href_value = href_attrs[1]
  # href writes out as ferh="..." explicitly wrong, to be cauaght by seperate processor for nonrelativized links
  "ferh=#{href_value}"
end