mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 19:00:39 -07:00
Use Expression.parse and Context#evaluate in the Condition class.
This commit is contained in:
@@ -28,9 +28,9 @@ module Liquid
|
|||||||
attr_accessor :left, :operator, :right
|
attr_accessor :left, :operator, :right
|
||||||
|
|
||||||
def initialize(left = nil, operator = nil, right = nil)
|
def initialize(left = nil, operator = nil, right = nil)
|
||||||
@left = left
|
@left = Expression.parse(left)
|
||||||
@operator = operator
|
@operator = operator
|
||||||
@right = right
|
@right = Expression.parse(right)
|
||||||
@child_relation = nil
|
@child_relation = nil
|
||||||
@child_condition = nil
|
@child_condition = nil
|
||||||
end
|
end
|
||||||
@@ -96,10 +96,10 @@ module Liquid
|
|||||||
# If the operator is empty this means that the decision statement is just
|
# If the operator is empty this means that the decision statement is just
|
||||||
# a single variable. We can just poll this variable from the context and
|
# a single variable. We can just poll this variable from the context and
|
||||||
# return this as the result.
|
# return this as the result.
|
||||||
return context[left] if op == nil
|
return context.evaluate(left) if op == nil
|
||||||
|
|
||||||
left = context[left]
|
left = context.evaluate(left)
|
||||||
right = context[right]
|
right = context.evaluate(right)
|
||||||
|
|
||||||
operation = self.class.operators[op] || raise(Liquid::ArgumentError.new("Unknown operator #{op}"))
|
operation = self.class.operators[op] || raise(Liquid::ArgumentError.new("Unknown operator #{op}"))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user