Freeze blocks in reverse order

This commit is contained in:
Peter Zhu
2020-12-16 15:18:34 -05:00
parent 7ca2846d9c
commit 51e8d6234a
3 changed files with 4 additions and 4 deletions

View File

@@ -21,7 +21,7 @@ module Liquid
def parse(tokens) def parse(tokens)
body = case_body = new_body body = case_body = new_body
body = @blocks.last.attachment while parse_body(body, tokens) body = @blocks.last.attachment while parse_body(body, tokens)
@blocks.each do |condition| @blocks.reverse_each do |condition|
body = condition.attachment body = condition.attachment
unless body.frozen? unless body.frozen?
body.remove_blank_strings if blank? body.remove_blank_strings if blank?

View File

@@ -63,11 +63,11 @@ module Liquid
parse_body(@else_block, tokens) parse_body(@else_block, tokens)
end end
if blank? if blank?
@for_block.remove_blank_strings
@else_block&.remove_blank_strings @else_block&.remove_blank_strings
@for_block.remove_blank_strings
end end
@for_block.freeze
@else_block&.freeze @else_block&.freeze
@for_block.freeze
end end
def nodelist def nodelist

View File

@@ -31,7 +31,7 @@ module Liquid
def parse(tokens) def parse(tokens)
while parse_body(@blocks.last.attachment, tokens) while parse_body(@blocks.last.attachment, tokens)
end end
@blocks.each do |block| @blocks.reverse_each do |block|
block.attachment.remove_blank_strings if blank? block.attachment.remove_blank_strings if blank?
block.attachment.freeze block.attachment.freeze
end end