mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Address comments
This commit is contained in:
@@ -11,7 +11,7 @@ module Liquid
|
||||
|
||||
def parse(tokens)
|
||||
@body = new_body
|
||||
while parse_body(@body, tokens, partial: true)
|
||||
while parse_body(@body, tokens)
|
||||
end
|
||||
@body.freeze
|
||||
end
|
||||
@@ -68,9 +68,7 @@ module Liquid
|
||||
end
|
||||
|
||||
# @api public
|
||||
def parse_body(body, tokens, partial: false)
|
||||
block_terminated = true
|
||||
|
||||
def parse_body(body, tokens)
|
||||
if parse_context.depth >= MAX_DEPTH
|
||||
raise StackLevelError, "Nesting too deep"
|
||||
end
|
||||
@@ -79,10 +77,7 @@ module Liquid
|
||||
body.parse(tokens, parse_context) do |end_tag_name, end_tag_params|
|
||||
@blank &&= body.blank?
|
||||
|
||||
if end_tag_name == block_delimiter
|
||||
block_terminated = false
|
||||
next
|
||||
end
|
||||
return false if end_tag_name == block_delimiter
|
||||
raise_tag_never_closed(block_name) unless end_tag_name
|
||||
|
||||
# this tag is not registered with the system
|
||||
@@ -93,12 +88,7 @@ module Liquid
|
||||
parse_context.depth -= 1
|
||||
end
|
||||
|
||||
unless partial
|
||||
body.remove_blank_strings if body.blank?
|
||||
body.freeze
|
||||
end
|
||||
|
||||
block_terminated
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -199,7 +199,7 @@ module Liquid
|
||||
end
|
||||
|
||||
def render_to_output_buffer(context, output)
|
||||
raise "Can only render when frozen" unless frozen?
|
||||
freeze unless frozen?
|
||||
|
||||
context.resource_limits.increment_render_score(@nodelist.length)
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@ module Liquid
|
||||
def parse(tokens)
|
||||
body = new_body
|
||||
body = @blocks.last.attachment while parse_body(body, tokens)
|
||||
if blank?
|
||||
@blocks.each { |condition| condition.attachment.remove_blank_strings }
|
||||
end
|
||||
@blocks.each { |condition| condition.attachment.freeze }
|
||||
end
|
||||
|
||||
def nodelist
|
||||
|
||||
@@ -62,6 +62,12 @@ module Liquid
|
||||
if parse_body(@for_block, tokens)
|
||||
parse_body(@else_block, tokens)
|
||||
end
|
||||
if blank?
|
||||
@for_block.remove_blank_strings
|
||||
@else_block&.remove_blank_strings
|
||||
end
|
||||
@for_block.freeze
|
||||
@else_block&.freeze
|
||||
end
|
||||
|
||||
def nodelist
|
||||
|
||||
@@ -31,6 +31,10 @@ module Liquid
|
||||
def parse(tokens)
|
||||
while parse_body(@blocks.last.attachment, tokens)
|
||||
end
|
||||
if blank?
|
||||
@blocks.each { |condition| condition.attachment.remove_blank_strings }
|
||||
end
|
||||
@blocks.each { |block| block.attachment.freeze }
|
||||
end
|
||||
|
||||
def unknown_tag(tag, markup, tokens)
|
||||
|
||||
Reference in New Issue
Block a user