mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 00:55:11 -07:00
Make logic in Context#lookup_and_evaluate more understandable
This commit is contained in:
@@ -205,10 +205,14 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def lookup_and_evaluate(obj, key)
|
def lookup_and_evaluate(obj, key)
|
||||||
if (value = obj[key]).is_a?(Proc) && obj.respond_to?(:[]=)
|
if @strict_variables && obj.respond_to?(:key?) && !obj.key?(key)
|
||||||
obj[key] = (value.arity == 0) ? value.call : value.call(self)
|
|
||||||
elsif strict_variables && obj.respond_to?(:key?) && !obj.key?(key)
|
|
||||||
raise Liquid::UndefinedVariable, "undefined variable #{key}"
|
raise Liquid::UndefinedVariable, "undefined variable #{key}"
|
||||||
|
end
|
||||||
|
|
||||||
|
value = obj[key]
|
||||||
|
|
||||||
|
if value.is_a?(Proc) && obj.respond_to?(:[]=)
|
||||||
|
obj[key] = (value.arity == 0) ? value.call : value.call(self)
|
||||||
else
|
else
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user