Class: Bridgetown::SeoTag

Inherits:
Liquid::Tag show all
Defined in:
lib/bridgetown-seo-tag.rb,
lib/bridgetown-seo-tag/drop.rb,
lib/bridgetown-seo-tag/builder.rb,
lib/bridgetown-seo-tag/filters.rb,
lib/bridgetown-seo-tag/version.rb,
lib/bridgetown-seo-tag/image_drop.rb,
lib/bridgetown-seo-tag/url_helper.rb,
lib/bridgetown-seo-tag/author_drop.rb

Defined Under Namespace

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

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

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.



27
28
29
30
# File 'lib/bridgetown-seo-tag.rb', line 27

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

Instance Attribute Details

#contextObject

Returns the value of attribute context.



14
15
16
# File 'lib/bridgetown-seo-tag.rb', line 14

def context
  @context
end

Class Method Details

.templateObject



77
78
79
# File 'lib/bridgetown-seo-tag.rb', line 77

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

Instance Method Details

#render(context) ⇒ Object



32
33
34
35
# File 'lib/bridgetown-seo-tag.rb', line 32

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