mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Merge pull request #1458 from Shopify/use-to-liquid-value-with-conditions
use Utils.to_liquid_value on conditionals
This commit is contained in:
@@ -134,8 +134,8 @@ module Liquid
|
|||||||
# return this as the result.
|
# return this as the result.
|
||||||
return context.evaluate(left) if op.nil?
|
return context.evaluate(left) if op.nil?
|
||||||
|
|
||||||
left = context.evaluate(left)
|
left = Liquid::Utils.to_liquid_value(context.evaluate(left))
|
||||||
right = context.evaluate(right)
|
right = Liquid::Utils.to_liquid_value(context.evaluate(right))
|
||||||
|
|
||||||
operation = self.class.operators[op] || raise(Liquid::ArgumentError, "Unknown operator #{op}")
|
operation = self.class.operators[op] || raise(Liquid::ArgumentError, "Unknown operator #{op}")
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ class VariableTest < Minitest::Test
|
|||||||
|
|
||||||
def test_if_tag_calls_to_liquid_value
|
def test_if_tag_calls_to_liquid_value
|
||||||
assert_template_result('one', '{% if foo == 1 %}one{% endif %}', 'foo' => IntegerDrop.new('1'))
|
assert_template_result('one', '{% if foo == 1 %}one{% endif %}', 'foo' => IntegerDrop.new('1'))
|
||||||
|
assert_template_result('one', '{% if 0 < foo %}one{% endif %}', 'foo' => IntegerDrop.new('1'))
|
||||||
|
assert_template_result('one', '{% if foo > 0 %}one{% endif %}', 'foo' => IntegerDrop.new('1'))
|
||||||
assert_template_result('true', '{% if foo == true %}true{% endif %}', 'foo' => BooleanDrop.new(true))
|
assert_template_result('true', '{% if foo == true %}true{% endif %}', 'foo' => BooleanDrop.new(true))
|
||||||
assert_template_result('true', '{% if foo %}true{% endif %}', 'foo' => BooleanDrop.new(true))
|
assert_template_result('true', '{% if foo %}true{% endif %}', 'foo' => BooleanDrop.new(true))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user