class Jekyll::SeoTag
Constants
- MINIFY_REGEX
Matches all whitespace that follows either
1. A '}', which closes a Liquid tag 2. A '{', which opens a JSON block 3. A '>' followed by a newline, which closes an XML tag or 4. A ',' followed by a newline, which ends a JSON line
We will strip all of this whitespace to minify the template We will not strip any whitespace if the next character is a ‘-’
so that we do not interfere with the HTML comment at the very begining
- VERSION
Attributes
context[RW]
Public Class Methods
new(_tag_name, text, _tokens)
click to toggle source
Calls superclass method
# File lib/jekyll-seo-tag.rb, line 29 def initialize(_tag_name, text, _tokens) super @text = text end
Private Class Methods
template()
click to toggle source
# File lib/jekyll-seo-tag.rb, line 73 def template @template ||= Liquid::Template.parse template_contents end
template_contents()
click to toggle source
# File lib/jekyll-seo-tag.rb, line 79 def template_contents @template_contents ||= begin File.read(template_path).gsub(MINIFY_REGEX, "") end end
template_path()
click to toggle source
# File lib/jekyll-seo-tag.rb, line 85 def template_path @template_path ||= begin File.expand_path "./template.html", File.dirname(__FILE__) end end
Public Instance Methods
render(context)
click to toggle source
# File lib/jekyll-seo-tag.rb, line 34 def render(context) @context = context SeoTag.template.render!(payload, info) end
Private Instance Methods
drop()
click to toggle source
# File lib/jekyll-seo-tag.rb, line 57 def drop if context.registers[:site].liquid_renderer.respond_to?(:cache) Jekyll::SeoTag::Drop.new(@text, @context) else @drop ||= Jekyll::SeoTag::Drop.new(@text, @context) end end
info()
click to toggle source
# File lib/jekyll-seo-tag.rb, line 65 def info { :registers => context.registers, :filters => [Jekyll::Filters], } end
options()
click to toggle source
# File lib/jekyll-seo-tag.rb, line 41 def options { "version" => Jekyll::SeoTag::VERSION, "title" => title?, } end
payload()
click to toggle source
# File lib/jekyll-seo-tag.rb, line 48 def payload # site_payload is an instance of UnifiedPayloadDrop. See https://git.io/v5ajm context.registers[:site].site_payload.tap do |site_payload| site_payload["page"] = context.registers[:page] site_payload["paginator"] = context["paginator"] site_payload["seo_tag"] = drop end end