Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only process Liquid template once #22

Merged
merged 1 commit into from
Jan 11, 2016
Merged

Only process Liquid template once #22

merged 1 commit into from
Jan 11, 2016

Conversation

pathawks
Copy link
Member

Very small performance optimization

def template_contents
@template_contents ||= File.read(template_path).gsub(/(>\n|[%}]})\s+(<|{[{%])/,'\1\2').chomp
def template
@template ||= Liquid::Template.parse(File.read(template_path).gsub(/(>\n|[%}]})\s+(<|{[{%])/,'\1\2').chomp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe keep template_contents to encapsulate the reading, and add template to encapsulate the parsing :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call

@benbalter
Copy link
Collaborator

Nice. Thanks @pathawks!

benbalter added a commit that referenced this pull request Jan 11, 2016
Only process Liquid template once
@benbalter benbalter merged commit 7a0ee09 into jekyll:master Jan 11, 2016
@pathawks pathawks deleted the liquid-once branch January 11, 2016 02:08
@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants