class Bunto::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/bunto-seo-tag.rb, line 23
def initialize(_tag_name, text, _tokens)
  super
  @text = text
end

Public Instance Methods

render(context) click to toggle source
# File lib/bunto-seo-tag.rb, line 28
def render(context)
  @context = context
  template.render!(payload, info)
end

Private Instance Methods

drop() click to toggle source
# File lib/bunto-seo-tag.rb, line 51
def drop
  @drop ||= Bunto::SeoTag::Drop.new(@text, @context)
end
info() click to toggle source
# File lib/bunto-seo-tag.rb, line 55
def info
  {
    :registers => context.registers,
    :filters   => [Bunto::Filters],
  }
end
options() click to toggle source
# File lib/bunto-seo-tag.rb, line 35
def options
  {
    "version" => Bunto::SeoTag::VERSION,
    "title"   => title?,
  }
end
payload() click to toggle source
# File lib/bunto-seo-tag.rb, line 42
def payload
  {
    "page"      => context.registers[:page],
    "site"      => context.registers[:site].site_payload["site"],
    "paginator" => context["paginator"],
    "seo_tag"   => drop,
  }
end
template() click to toggle source
# File lib/bunto-seo-tag.rb, line 62
def template
  @template ||= Liquid::Template.parse template_contents
end
template_contents() click to toggle source
# File lib/bunto-seo-tag.rb, line 66
def template_contents
  @template_contents ||= begin
    File.read(template_path).gsub(MINIFY_REGEX, "")
  end
end
template_path() click to toggle source
# File lib/bunto-seo-tag.rb, line 72
def template_path
  @template_path ||= begin
    File.expand_path "./template.html", File.dirname(__FILE__)
  end
end