mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-16 09:20:42 -07:00
Changing to keep default_proc support
This commit is contained in:
@@ -164,7 +164,7 @@ module Liquid
|
||||
# This was changed from find() to find_index() because this is a very hot
|
||||
# path and find_index() is optimized in MRI to reduce object allocation
|
||||
scope = (index = @scopes.find_index { |s| s.key?(key) }) && @scopes[index]
|
||||
scope ||= (index = @environments.find_index { |s| s.key?(key) }) && @environments[index]
|
||||
scope ||= (index = @environments.find_index { |s| s.key?(key) || !s.default_proc.nil? }) && @environments[index]
|
||||
scope ||= {}
|
||||
|
||||
variable = lookup_and_evaluate(scope, key, raise_on_not_found: raise_on_not_found).to_liquid
|
||||
|
||||
@@ -80,7 +80,10 @@ class VariableTest < Minitest::Test
|
||||
assigns['test'] = 'Tobi'
|
||||
assert_equal 'Hello Tobi', template.render!(assigns)
|
||||
assigns.delete('test')
|
||||
assert_equal "Hello ", template.render!(assigns)
|
||||
e = assert_raises(RuntimeError) do
|
||||
template.render!(assigns)
|
||||
end
|
||||
assert_equal "Unknown variable 'test'", e.message
|
||||
end
|
||||
|
||||
def test_environment_falsy
|
||||
|
||||
Reference in New Issue
Block a user