Only process Liquid template once

This commit is contained in:
Pat Hawks 2016-01-10 16:49:18 -08:00
parent 85934ae5de
commit 5672ec3991
No known key found for this signature in database
GPG Key ID: F1746FF5F18B3D1B
1 changed files with 5 additions and 1 deletions

View File

@ -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