mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Fix post-trim for the raw tag
The added test did not pass before this commit.
This commit is contained in:
@@ -16,7 +16,10 @@ module Liquid
|
|||||||
while (token = tokens.shift)
|
while (token = tokens.shift)
|
||||||
if token =~ FullTokenPossiblyInvalid
|
if token =~ FullTokenPossiblyInvalid
|
||||||
@body << Regexp.last_match(1) if Regexp.last_match(1) != ""
|
@body << Regexp.last_match(1) if Regexp.last_match(1) != ""
|
||||||
return if block_delimiter == Regexp.last_match(2)
|
if block_delimiter == Regexp.last_match(2)
|
||||||
|
@parse_context.trim_whitespace = (token[-3] == WhitespaceControl)
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@body << token unless token.empty?
|
@body << token unless token.empty?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ class RawTagTest < Minitest::Test
|
|||||||
assert_template_result('{{ test }}', '{% raw %}{{ test }}{% endraw %}')
|
assert_template_result('{{ test }}', '{% raw %}{{ test }}{% endraw %}')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_post_trim
|
||||||
|
assert_template_result('hi', "{% raw %}hi{% endraw -%}\n")
|
||||||
|
end
|
||||||
|
|
||||||
def test_open_tag_in_raw
|
def test_open_tag_in_raw
|
||||||
assert_template_result(' Foobar {% invalid ', '{% raw %} Foobar {% invalid {% endraw %}')
|
assert_template_result(' Foobar {% invalid ', '{% raw %} Foobar {% invalid {% endraw %}')
|
||||||
assert_template_result(' Foobar invalid %} ', '{% raw %} Foobar invalid %} {% endraw %}')
|
assert_template_result(' Foobar invalid %} ', '{% raw %} Foobar invalid %} {% endraw %}')
|
||||||
|
|||||||
Reference in New Issue
Block a user