Sha256: 22fe699ff584a7019fc2f712c785f15a27dcaaac164e25ff672a85cc77753865
Contents?: true
Size: 1.34 KB
Versions: 5
Compression:
Stored size: 1.34 KB
Contents
require 'bunto-seo-tag/filters' require 'bunto-seo-tag/version' module Bunto class SeoTag < Liquid::Tag attr_accessor :context MINIFY_REGEX = /([>,]\n|[%}]})\s+?(<|{[{%]|[ ]+\")/ def initialize(_tag_name, text, _tokens) super @text = text end def render(context) @context = context template.render!(payload, info) end private def options { 'version' => Bunto::SeoTag::VERSION, 'title' => title? } end def payload { 'page' => context.registers[:page], 'site' => context.registers[:site].site_payload['site'], 'seo_tag' => options } end def title? !(@text =~ /title=false/i) end def info { registers: context.registers, filters: [Bunto::Filters, BuntoSeoTag::Filters] } end def template @template ||= Liquid::Template.parse template_contents end def template_contents @template_contents ||= begin File.read(template_path).gsub(MINIFY_REGEX, '\1\2').chomp end end def template_path @template_path ||= begin File.expand_path './template.html', File.dirname(__FILE__) end end end end Liquid::Template.register_tag('seo', Bunto::SeoTag)
Version data entries
5 entries across 5 versions & 1 rubygems