diff --git a/lib/jekyll-seo-tag.rb b/lib/jekyll-seo-tag.rb index 5fb9800..9f6313f 100644 --- a/lib/jekyll-seo-tag.rb +++ b/lib/jekyll-seo-tag.rb @@ -11,7 +11,7 @@ module Jekyll def render(context) @context = context - output = Liquid::Template.parse(template_contents).render!(payload, info) + output = template.render!(payload, info) # Encode smart quotes. See https://github.com/benbalter/jekyll-seo-tag/pull/6 output.gsub!(HTML_ESCAPE_REGEX, HTML_ESCAPE) @@ -35,6 +35,10 @@ module Jekyll } end + def template + @template ||= Liquid::Template.parse template_contents + end + def template_contents @template_contents ||= File.read(template_path).gsub(/(>\n|[%}]})\s+(<|{[{%])/,'\1\2').chomp end