mirror of
https://github.com/kemko/liquid.git
synced 2026-01-04 17:25:41 +03: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:
|
||||
Max: 294
|
||||
|
||||
# Offense count: 1
|
||||
Metrics/BlockNesting:
|
||||
Max: 4
|
||||
|
||||
# Offense count: 44
|
||||
Naming/ConstantName:
|
||||
Exclude:
|
||||
@@ -49,4 +45,4 @@ Style/ClassVars:
|
||||
Exclude:
|
||||
- 'lib/liquid/condition.rb'
|
||||
- 'lib/liquid/strainer.rb'
|
||||
- 'lib/liquid/template.rb'
|
||||
- 'lib/liquid/template.rb'
|
||||
@@ -60,6 +60,14 @@ module Liquid
|
||||
Usage.increment("liquid_tag_contains_outer_tag") unless $ERROR_INFO.is_a?(SyntaxError)
|
||||
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)
|
||||
while (token = tokenizer.shift)
|
||||
next if token.empty?
|
||||
@@ -79,11 +87,7 @@ module Liquid
|
||||
end
|
||||
|
||||
if tag_name == 'liquid'
|
||||
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
|
||||
parse_liquid_tag(markup, parse_context, &block)
|
||||
next
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user