Pass the tag markup and tokenizer to Document#unknown_tag

The parse_context no longer needs to be passed in because it is available
through through an attr_reader on the instance. However, the markup and
tokenizer weren't made available.  This refactor also makes the parameters
given to Document#unknown_tag consistent with Block#unknown_tag.
This commit is contained in:
Dylan Thacker-Smith
2020-09-07 21:03:20 -04:00
parent 95ff0595c6
commit 86b47ba28b

View File

@@ -19,16 +19,15 @@ module Liquid
@body.nodelist
end
def parse(tokens, parse_context)
@body.parse(tokens, parse_context) do |end_tag_name, _end_tag_params|
unknown_tag(end_tag_name, parse_context) if end_tag_name
def parse(tokenizer, parse_context)
while parse_body(tokenizer)
end
rescue SyntaxError => e
e.line_number ||= parse_context.line_number
raise
end
def unknown_tag(tag, parse_context)
def unknown_tag(tag, _markup, _tokenizer)
case tag
when 'else', 'end'
raise SyntaxError, parse_context.locale.t("errors.syntax.unexpected_outer_tag", tag: tag)
@@ -50,5 +49,16 @@ module Liquid
def new_body
parse_context.new_block_body
end
def parse_body(tokenizer)
@body.parse(tokenizer, parse_context) do |unknown_tag_name, unknown_tag_markup|
if unknown_tag_name
unknown_tag(unknown_tag_name, unknown_tag_markup, tokenizer)
true
else
false
end
end
end
end
end