mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 00:55:11 -07:00
Merge pull request #1345 from Shopify/pz-fix-tags-in-comment
Fix tags in comment
This commit is contained in:
@@ -109,14 +109,22 @@ module Liquid
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private def parse_for_document(tokenizer, parse_context)
|
private def handle_invalid_tag_token(token, parse_context)
|
||||||
|
if token.end_with?('%}')
|
||||||
|
yield token, token
|
||||||
|
else
|
||||||
|
BlockBody.raise_missing_tag_terminator(token, parse_context)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
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?
|
||||||
case
|
case
|
||||||
when token.start_with?(TAGSTART)
|
when token.start_with?(TAGSTART)
|
||||||
whitespace_handler(token, parse_context)
|
whitespace_handler(token, parse_context)
|
||||||
unless token =~ FullToken
|
unless token =~ FullToken
|
||||||
BlockBody.raise_missing_tag_terminator(token, parse_context)
|
return handle_invalid_tag_token(token, parse_context, &block)
|
||||||
end
|
end
|
||||||
tag_name = Regexp.last_match(2)
|
tag_name = Regexp.last_match(2)
|
||||||
markup = Regexp.last_match(4)
|
markup = Regexp.last_match(4)
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ class StandardTagTest < Minitest::Test
|
|||||||
assert_template_result('', '{%comment%}{% endif %}{%endcomment%}')
|
assert_template_result('', '{%comment%}{% endif %}{%endcomment%}')
|
||||||
assert_template_result('', '{% comment %}{% endwhatever %}{% endcomment %}')
|
assert_template_result('', '{% comment %}{% endwhatever %}{% endcomment %}')
|
||||||
assert_template_result('', '{% comment %}{% raw %} {{%%%%}} }} { {% endcomment %} {% comment {% endraw %} {% endcomment %}')
|
assert_template_result('', '{% comment %}{% raw %} {{%%%%}} }} { {% endcomment %} {% comment {% endraw %} {% endcomment %}')
|
||||||
|
assert_template_result('', '{% comment %}{% " %}{% endcomment %}')
|
||||||
|
assert_template_result('', '{% comment %}{%%}{% endcomment %}')
|
||||||
|
|
||||||
assert_template_result('foobar', 'foo{%comment%}comment{%endcomment%}bar')
|
assert_template_result('foobar', 'foo{%comment%}comment{%endcomment%}bar')
|
||||||
assert_template_result('foobar', 'foo{% comment %}comment{% endcomment %}bar')
|
assert_template_result('foobar', 'foo{% comment %}comment{% endcomment %}bar')
|
||||||
|
|||||||
Reference in New Issue
Block a user