mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-18 18:30:40 -07:00
Fix line number tracking after a non-empty blank token
This commit is contained in:
@@ -27,11 +27,11 @@ module Liquid
|
|||||||
private def parse_for_liquid_tag(tokenizer, parse_context)
|
private def parse_for_liquid_tag(tokenizer, parse_context)
|
||||||
while token = tokenizer.shift
|
while token = tokenizer.shift
|
||||||
case
|
case
|
||||||
when token.empty?
|
when token.empty? || token =~ WhitespaceOrNothing
|
||||||
# pass
|
# pass, but assign line_number below, since it could change even when
|
||||||
|
# the token is empty
|
||||||
else
|
else
|
||||||
unless token =~ LiquidTagToken
|
unless token =~ LiquidTagToken
|
||||||
next if token =~ WhitespaceOrNothing
|
|
||||||
# line isn't empty but didn't match tag syntax, yield and let the
|
# line isn't empty but didn't match tag syntax, yield and let the
|
||||||
# caller raise a syntax error
|
# caller raise a syntax error
|
||||||
return yield token, token
|
return yield token, token
|
||||||
|
|||||||
@@ -74,6 +74,11 @@ class LiquidTagTest < Minitest::Test
|
|||||||
LIQUID
|
LIQUID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_line_number_is_correct_after_a_blank_token
|
||||||
|
assert_match_syntax_error("syntax error (line 3): Unknown tag 'error'", "{% liquid echo ''\n\n error %}")
|
||||||
|
assert_match_syntax_error("syntax error (line 3): Unknown tag 'error'", "{% liquid echo ''\n \n error %}")
|
||||||
|
end
|
||||||
|
|
||||||
def test_cannot_open_blocks_living_past_a_liquid_tag
|
def test_cannot_open_blocks_living_past_a_liquid_tag
|
||||||
assert_match_syntax_error("syntax error (line 3): 'if' tag was never closed", <<~LIQUID)
|
assert_match_syntax_error("syntax error (line 3): 'if' tag was never closed", <<~LIQUID)
|
||||||
{%- liquid
|
{%- liquid
|
||||||
|
|||||||
Reference in New Issue
Block a user