Compare commits

...

2 Commits

Author SHA1 Message Date
Guillaume Malette
42e5c52336
Merge pull request #1717 from Shopify/gm/fix-raw-trimmode-at-end-of-block
[trim] Fix trimming at end of raw block when specified in the opening tag
2023-05-19 14:08:02 -04:00
Guillaume Malette
649cca1349
[trim] Fix trimming at end of raw block when specified in the opening tag 2023-05-19 11:41:45 -04:00
2 changed files with 3 additions and 1 deletions

View File

@ -26,6 +26,7 @@ module Liquid
@body = +'' @body = +''
while (token = tokens.shift) while (token = tokens.shift)
if token =~ FullTokenPossiblyInvalid && block_delimiter == Regexp.last_match(2) if token =~ FullTokenPossiblyInvalid && block_delimiter == Regexp.last_match(2)
parse_context.trim_whitespace = (token[-3] == WhitespaceControl)
@body << Regexp.last_match(1) if Regexp.last_match(1) != "" @body << Regexp.last_match(1) if Regexp.last_match(1) != ""
return return
end end

View File

@ -13,8 +13,9 @@ class RawTagTest < Minitest::Test
end end
def test_output_in_raw def test_output_in_raw
# assert_template_result('{{ test }}', '{% raw %}{{ test }}{% endraw %}')
assert_template_result('>{{ test }}<', '> {%- raw -%}{{ test }}{%- endraw -%} <') assert_template_result('>{{ test }}<', '> {%- raw -%}{{ test }}{%- endraw -%} <')
assert_template_result("> inner <", "> {%- raw -%} inner {%- endraw %} <")
assert_template_result("> inner <", "> {%- raw -%} inner {%- endraw -%} <")
end end
def test_open_tag_in_raw def test_open_tag_in_raw