From 7b2b25fda1ff025b7ec790cdd28fb9535de96f3d Mon Sep 17 00:00:00 2001 From: James Meng Date: Mon, 9 Jun 2025 11:36:18 -0700 Subject: [PATCH] Fix Doc tag blank? method to check body content Previously the blank? method always returned true. Now it properly checks if the body is empty, making the tag behavior consistent with other tags. Also updated test to use whitespace control for cleaner assertions. --- lib/liquid/tags/doc.rb | 2 +- test/unit/tags/doc_tag_unit_test.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/liquid/tags/doc.rb b/lib/liquid/tags/doc.rb index b61d7e95..499102d7 100644 --- a/lib/liquid/tags/doc.rb +++ b/lib/liquid/tags/doc.rb @@ -59,7 +59,7 @@ module Liquid end def blank? - true + @body.empty? end def nodelist diff --git a/test/unit/tags/doc_tag_unit_test.rb b/test/unit/tags/doc_tag_unit_test.rb index 7c6ef6f3..64b950b7 100644 --- a/test/unit/tags/doc_tag_unit_test.rb +++ b/test/unit/tags/doc_tag_unit_test.rb @@ -174,11 +174,11 @@ class DocTagUnitTest < Minitest::Test def test_doc_tag_delimiter_handling assert_template_result('', <<~LIQUID.chomp) - {% if true %} - {% doc %} - {% docEXTRA %}wut{% enddocEXTRA %}xyz - {% enddoc %} - {% endif %} + {%- if true -%} + {%- doc -%} + {%- docEXTRA -%}wut{% enddocEXTRA -%}xyz + {%- enddoc -%} + {%- endif -%} LIQUID assert_template_result('', "{% doc %}123{% enddoc xyz %}")