Skip to content

Commit

Permalink
Merge pull request #1735 from Shopify/marco-condition-to-liquid-value
Browse files Browse the repository at this point in the history
Call to_liquid_value when short circuiting conditions
  • Loading branch information
samdoiron authored Jul 19, 2023
2 parents 5e92b3a + 21d6197 commit 0b93182
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/liquid/condition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def evaluate(context = deprecated_default_context)

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
Expand Down
1 change: 1 addition & 0 deletions test/integration/variable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def test_if_tag_calls_to_liquid_value

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
Expand Down

0 comments on commit 0b93182

Please sign in to comment.