Skip to content

Commit

Permalink
Clear cached Liquid template scope before render (#7967)
Browse files Browse the repository at this point in the history
Merge pull request 7967
  • Loading branch information
ashmaroli committed Apr 13, 2020
1 parent 1cf04b8 commit 67380a2
Showing 1 changed file with 10 additions and 0 deletions.
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

0 comments on commit 67380a2

Please sign in to comment.