mirror of
https://github.com/Shopify/liquid.git
synced 2025-11-27 00:00:34 -05:00
Fix broken rendering of variables which are equal to false (closes #345)
This commit is contained in:
parent
f15d24509d
commit
2a12f253bf
@ -194,7 +194,8 @@ module Liquid
|
|||||||
|
|
||||||
if scope.nil?
|
if scope.nil?
|
||||||
@environments.each do |e|
|
@environments.each do |e|
|
||||||
if variable = lookup_and_evaluate(e, key)
|
variable = lookup_and_evaluate(e, key)
|
||||||
|
unless variable.nil?
|
||||||
scope = e
|
scope = e
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|||||||
@ -20,5 +20,4 @@ class ContextTest < Test::Unit::TestCase
|
|||||||
assert_equal 'Global test', Template.parse("{{'test' | notice }}").render!
|
assert_equal 'Global test', Template.parse("{{'test' | notice }}").render!
|
||||||
assert_equal 'Local test', Template.parse("{{'test' | notice }}").render!({}, :filters => [local])
|
assert_equal 'Local test', Template.parse("{{'test' | notice }}").render!({}, :filters => [local])
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -25,6 +25,10 @@ class VariableTest < Test::Unit::TestCase
|
|||||||
assert_equal 'worked', template.render!('test' => {'test' => 'worked'})
|
assert_equal 'worked', template.render!('test' => {'test' => 'worked'})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_false_renders_as_false
|
||||||
|
assert_equal 'false', Template.parse("{{ foo }}").render!('foo' => false)
|
||||||
|
end
|
||||||
|
|
||||||
def test_preset_assigns
|
def test_preset_assigns
|
||||||
template = Template.parse(%|{{ test }}|)
|
template = Template.parse(%|{{ test }}|)
|
||||||
template.assigns['test'] = 'worked'
|
template.assigns['test'] = 'worked'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user