diff --git a/lib/liquid/block_body.rb b/lib/liquid/block_body.rb index 9999826..371e058 100644 --- a/lib/liquid/block_body.rb +++ b/lib/liquid/block_body.rb @@ -69,7 +69,6 @@ module Liquid def render(context) output = [] - context.resource_limits.render_length = 0 context.resource_limits.render_score += @nodelist.length @nodelist.each do |token| diff --git a/lib/liquid/resource_limits.rb b/lib/liquid/resource_limits.rb index 6373130..190685e 100644 --- a/lib/liquid/resource_limits.rb +++ b/lib/liquid/resource_limits.rb @@ -7,10 +7,7 @@ module Liquid @render_length_limit = limits[:render_length_limit] @render_score_limit = limits[:render_score_limit] @assign_score_limit = limits[:assign_score_limit] - - # render_length is assigned by BlockBody - @render_score = 0 - @assign_score = 0 + reset end def reached? @@ -18,5 +15,9 @@ module Liquid (@render_score_limit && @render_score > @render_score_limit ) || (@assign_score_limit && @assign_score > @assign_score_limit ) end + + def reset + @render_length = @render_score = @assign_score = 0 + end end end diff --git a/lib/liquid/template.rb b/lib/liquid/template.rb index 9928c81..2ad7c42 100644 --- a/lib/liquid/template.rb +++ b/lib/liquid/template.rb @@ -205,6 +205,9 @@ module Liquid context.add_filters(args.pop) end + # Retrying a render resets resource usage + context.resource_limits.reset + begin # render the nodelist. # for performance reasons we get an array back here. join will make a string out of it.