mirror of
https://github.com/kemko/liquid.git
synced 2026-01-06 10:15:40 +03:00
Make logic in Context#lookup_and_evaluate more understandable
This commit is contained in:
@@ -205,10 +205,14 @@ module Liquid
|
||||
end
|
||||
|
||||
def lookup_and_evaluate(obj, key)
|
||||
if (value = obj[key]).is_a?(Proc) && obj.respond_to?(:[]=)
|
||||
obj[key] = (value.arity == 0) ? value.call : value.call(self)
|
||||
elsif strict_variables && obj.respond_to?(:key?) && !obj.key?(key)
|
||||
if @strict_variables && obj.respond_to?(:key?) && !obj.key?(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
|
||||
value
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user