Merge pull request #22 from pathawks/liquid-once

Only process Liquid template once
This commit is contained in:
Ben Balter 2016-01-10 21:06:08 -05:00
commit 7a0ee09e22
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