Call to_liquid_value when short circuiting conditions

This commit is contained in:
Marco Rudilosso
2023-07-19 15:22:12 +00:00
parent 5e92b3a89a
commit 21d6197533
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -69,9 +69,9 @@ module Liquid
case condition.child_relation
when :or
break if result
break if Liquid::Utils.to_liquid_value(result)
when :and
break unless result
break unless Liquid::Utils.to_liquid_value(result)
else
break
end
+1
View File
@@ -34,6 +34,7 @@ class VariableTest < Minitest::Test
assert_template_result('', '{% if foo %}true{% endif %}', { 'foo' => BooleanDrop.new(false) })
assert_template_result('', '{% if foo == true %}True{% endif %}', { 'foo' => BooleanDrop.new(false) })
assert_template_result('', '{% if foo and true %}SHOULD NOT HAPPEN{% endif %}', { 'foo' => BooleanDrop.new(false) })
assert_template_result('one', '{% if a contains x %}one{% endif %}', { 'a' => [1], 'x' => IntegerDrop.new(1) })
end