Skip to content

Commit

Permalink
Merge pull request #231 from jekyll/cache-template
Browse files Browse the repository at this point in the history
Cache parsed template
  • Loading branch information
benbalter authored Aug 24, 2017
2 parents 9dc5b01 + d893fc7 commit 29cbdee
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/jekyll-seo-tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(_tag_name, text, _tokens)

def render(context)
@context = context
template.render!(payload, info)
SeoTag.template.render!(payload, info)
end

private
Expand Down Expand Up @@ -63,19 +63,23 @@ def info
}
end

def template
@template ||= Liquid::Template.parse template_contents
end
class << self
def template
@template ||= Liquid::Template.parse template_contents
end

def template_contents
@template_contents ||= begin
File.read(template_path).gsub(MINIFY_REGEX, "")
private

def template_contents
@template_contents ||= begin
File.read(template_path).gsub(MINIFY_REGEX, "")
end
end
end

def template_path
@template_path ||= begin
File.expand_path "./template.html", File.dirname(__FILE__)
def template_path
@template_path ||= begin
File.expand_path "./template.html", File.dirname(__FILE__)

This comment has been minimized.

Copy link
@DirtyF

DirtyF Aug 26, 2017

Member

another __dir__ candidate here

end
end
end
end
Expand Down

0 comments on commit 29cbdee

Please sign in to comment.