mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 19:30:47 -07:00
Extract snippet resource scoring logic into assign_score_of
This commit is contained in:
@@ -27,15 +27,18 @@ module Liquid
|
|||||||
def render_to_output_buffer(context, output)
|
def render_to_output_buffer(context, output)
|
||||||
snippet_drop = SnippetDrop.new(@body, @to)
|
snippet_drop = SnippetDrop.new(@body, @to)
|
||||||
context.scopes.last[@to] = snippet_drop
|
context.scopes.last[@to] = snippet_drop
|
||||||
|
context.resource_limits.increment_assign_score(assign_score_of(snippet_drop))
|
||||||
snippet_size = @body.nodelist.sum { |node| node.to_s.bytesize }
|
|
||||||
context.resource_limits.increment_assign_score(snippet_size)
|
|
||||||
|
|
||||||
output
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
def blank?
|
def blank?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def assign_score_of(snippet_drop)
|
||||||
|
snippet_drop.body.nodelist.sum { |node| node.to_s.bytesize }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user