Class: Jekyll::SeoTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/starter_web/_plugins/seo/j1-seo-tags.rb,
lib/starter_web/_plugins/seo/j1-seo-tags.rb,
lib/starter_web/_plugins/seo/j1-seo-tags.rb,
lib/starter_web/_plugins/seo/j1-seo-tags.rb,
lib/starter_web/_plugins/seo/j1-seo-tags.rb,
lib/starter_web/_plugins/seo/j1-seo-tags.rb

Defined Under Namespace

Modules: UrlHelper Classes: AuthorDrop, Drop, Filters, ImageDrop, JSONLDDrop

Constant Summary collapse

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 beginning
%r!(?<=[{}]|[>,]\n)\s+(?\!-)!.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_tag_name, text, _tokens) ⇒ SeoTag

Returns a new instance of SeoTag.



97
98
99
100
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 97

def initialize(_tag_name, text, _tokens)
  super
  @text = text
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



73
74
75
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 73

def context
  @context
end

Class Method Details

.templateObject



140
141
142
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 140

def template
  @template ||= Liquid::Template.parse template_contents
end

Instance Method Details

#render(context) ⇒ Object



102
103
104
105
# File 'lib/starter_web/_plugins/seo/j1-seo-tags.rb', line 102

def render(context)
  @context = context
  SeoTag.template.render!(payload, info)
end