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

Backport #7967 for v4.0.x #8141

Merged
merged 2 commits into from Apr 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/jekyll/liquid_renderer/file.rb
Expand Up @@ -18,6 +18,8 @@ def parse(content)
end

def render(*args)
reset_template_assigns

measure_time do
measure_bytes do
measure_counts do
Expand All @@ -29,6 +31,8 @@ def render(*args)

# This method simply 'rethrows any error' before attempting to render the template.
def render!(*args)
reset_template_assigns

measure_time do
measure_bytes do
measure_counts do
Expand All @@ -44,6 +48,12 @@ def warnings

private

# clear assigns to `Liquid::Template` instance prior to rendering since
# `Liquid::Template` instances are cached in Jekyll 4.
def reset_template_assigns
@template.instance_assigns.clear
end

def measure_counts
@renderer.increment_count(@filename)
yield
Expand Down