Skip to content

Commit 5672ec3

Browse files
committed
Only process Liquid template once
1 parent 85934ae commit 5672ec3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/jekyll-seo-tag.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class SeoTag < Liquid::Tag
1111

1212
def render(context)
1313
@context = context
14-
output = Liquid::Template.parse(template_contents).render!(payload, info)
14+
output = template.render!(payload, info)
1515

1616
# Encode smart quotes. See https://github.com/benbalter/jekyll-seo-tag/pull/6
1717
output.gsub!(HTML_ESCAPE_REGEX, HTML_ESCAPE)
@@ -35,6 +35,10 @@ def info
3535
}
3636
end
3737

38+
def template
39+
@template ||= Liquid::Template.parse template_contents
40+
end
41+
3842
def template_contents
3943
@template_contents ||= File.read(template_path).gsub(/(>\n|[%}]})\s+(<|{[{%])/,'\1\2').chomp
4044
end

0 commit comments

Comments
 (0)