Skip to content

Commit

Permalink
don't reset Liquid tag's whitespace control from comment tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ggmichaelgo committed Jan 5, 2024
1 parent 96a0363 commit dab4000
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/liquid/tags/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def parse_body(body, tokenizer)
comment_tag_depth -= 1

if comment_tag_depth.zero?
parse_context.trim_whitespace = (token[-3] == WhitespaceControl)
parse_context.trim_whitespace = (token[-3] == WhitespaceControl) unless tokenizer.for_liquid_tag
return false
end
end
Expand Down
12 changes: 12 additions & 0 deletions test/unit/tags/comment_tag_unit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,16 @@ def test_with_whitespace_control
Hello!
LIQUID
end

def test_dont_override_liquid_tag_whitespace_control
assert_template_result("Hello!World!", <<~LIQUID.chomp)
Hello!
{%- liquid
comment
this is inside a liquid tag
endcomment
-%}
World!
LIQUID
end
end

0 comments on commit dab4000

Please sign in to comment.