mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 09:05:13 -07:00
style: Avoid deep nesting for parsing the liquid tag in the block body
This commit is contained in:
@@ -21,10 +21,6 @@ Lint/InheritException:
|
|||||||
Layout/LineLength:
|
Layout/LineLength:
|
||||||
Max: 294
|
Max: 294
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
Metrics/BlockNesting:
|
|
||||||
Max: 4
|
|
||||||
|
|
||||||
# Offense count: 44
|
# Offense count: 44
|
||||||
Naming/ConstantName:
|
Naming/ConstantName:
|
||||||
Exclude:
|
Exclude:
|
||||||
|
|||||||
@@ -60,6 +60,14 @@ module Liquid
|
|||||||
Usage.increment("liquid_tag_contains_outer_tag") unless $ERROR_INFO.is_a?(SyntaxError)
|
Usage.increment("liquid_tag_contains_outer_tag") unless $ERROR_INFO.is_a?(SyntaxError)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private def parse_liquid_tag(markup, parse_context, &block)
|
||||||
|
liquid_tag_tokenizer = Tokenizer.new(markup, line_number: parse_context.line_number, for_liquid_tag: true)
|
||||||
|
parse_for_liquid_tag(liquid_tag_tokenizer, parse_context) do |end_tag_name, end_tag_markup|
|
||||||
|
next unless end_tag_name
|
||||||
|
self.class.unknown_tag_in_liquid_tag(end_tag_name, end_tag_markup, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private def parse_for_document(tokenizer, parse_context, &block)
|
private def parse_for_document(tokenizer, parse_context, &block)
|
||||||
while (token = tokenizer.shift)
|
while (token = tokenizer.shift)
|
||||||
next if token.empty?
|
next if token.empty?
|
||||||
@@ -79,11 +87,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
if tag_name == 'liquid'
|
if tag_name == 'liquid'
|
||||||
liquid_tag_tokenizer = Tokenizer.new(markup, line_number: parse_context.line_number, for_liquid_tag: true)
|
parse_liquid_tag(markup, parse_context, &block)
|
||||||
parse_for_liquid_tag(liquid_tag_tokenizer, parse_context) do |end_tag_name, end_tag_markup|
|
|
||||||
next unless end_tag_name
|
|
||||||
self.class.unknown_tag_in_liquid_tag(end_tag_name, end_tag_markup, &block)
|
|
||||||
end
|
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user