Class: Jekyll::SeoTag

Inherits:
Liquid::Tag show all
Defined in:
lib/jekyll-seo-tag.rb,
lib/jekyll-seo-tag/version.rb

Constant Summary collapse

HTML_ESCAPE =
{
  "\u201c".freeze => '“'.freeze,
  "\u201d".freeze => '”'.freeze
}
HTML_ESCAPE_REGEX =
Regexp.union(HTML_ESCAPE.keys).freeze
VERSION =
"0.1.4"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject

Returns the value of attribute context.



4
5
6
# File 'lib/jekyll-seo-tag.rb', line 4

def context
  @context
end

Instance Method Details

#render(context) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/jekyll-seo-tag.rb', line 12

def render(context)
  @context = context
  output = Liquid::Template.parse(template_contents).render!(payload, info)

  # Encode smart quotes. See https://github.com/benbalter/jekyll-seo-tag/pull/6
  output.gsub!(HTML_ESCAPE_REGEX, HTML_ESCAPE)

  output
end