class Bridgetown::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/bridgetown-seo-tag.rb, line 27 def initialize(_tag_name, text, _tokens) super @text = text end
Private Class Methods
template()
click to toggle source
# File lib/bridgetown-seo-tag.rb, line 77 def template @template ||= Liquid::Template.parse template_contents end
template_contents()
click to toggle source
# File lib/bridgetown-seo-tag.rb, line 83 def template_contents @template_contents ||= begin File.read(template_path).gsub(MINIFY_REGEX, "") end end
template_path()
click to toggle source
# File lib/bridgetown-seo-tag.rb, line 89 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/bridgetown-seo-tag.rb, line 32 def render(context) @context = context SeoTag.template.render!(payload, info) end
Private Instance Methods
drop()
click to toggle source
# File lib/bridgetown-seo-tag.rb, line 58 def drop if context.registers[:site].liquid_renderer.respond_to?(:cache) Bridgetown::SeoTag::Drop.new(@text, context) else @drop ||= Bridgetown::SeoTag::Drop.new(@text, context) end end
info()
click to toggle source
# File lib/bridgetown-seo-tag.rb, line 66 def info { registers: { site: context.registers[:site], page: context.registers[:page], }, filters: [Bridgetown::Filters], } end
options()
click to toggle source
# File lib/bridgetown-seo-tag.rb, line 39 def options { "version" => Bridgetown::SeoTag::VERSION, "title" => title?, } end
payload()
click to toggle source
# File lib/bridgetown-seo-tag.rb, line 46 def payload paginator = context.registers[:page].pager if context.registers[:page].respond_to?(:pager) # site_payload is an instance of UnifiedPayloadDrop Bridgetown::Utils.deep_merge_hashes( context.registers[:site].site_payload, "page" => context.registers[:page], "paginator" => paginator, "seo_tag" => drop ) end