mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 09:05:13 -07:00
Fixed ComparisonExpression.parse with MethodLiterals
This commit is contained in:
+10
-2
@@ -52,6 +52,10 @@ module Liquid
|
|||||||
@@method_literals[markup] || parse_context.parse_expression(markup)
|
@@method_literals[markup] || parse_context.parse_expression(markup)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.parse(markup, ss, cache)
|
||||||
|
@@method_literals[markup] || Expression.parse(markup, ss, cache)
|
||||||
|
end
|
||||||
|
|
||||||
attr_reader :attachment, :child_condition
|
attr_reader :attachment, :child_condition
|
||||||
attr_accessor :left, :operator, :right
|
attr_accessor :left, :operator, :right
|
||||||
|
|
||||||
@@ -112,11 +116,15 @@ module Liquid
|
|||||||
private
|
private
|
||||||
|
|
||||||
def equal_variables(left, right)
|
def equal_variables(left, right)
|
||||||
|
if left.is_a?(MethodLiteral) && right.is_a?(MethodLiteral)
|
||||||
|
return left.to_s == right.to_s
|
||||||
|
end
|
||||||
|
|
||||||
if left.is_a?(MethodLiteral)
|
if left.is_a?(MethodLiteral)
|
||||||
if right.respond_to?(left.method_name)
|
if right.respond_to?(left.method_name)
|
||||||
return right.send(left.method_name)
|
return right.send(left.method_name)
|
||||||
else
|
else
|
||||||
return nil
|
return left.to_s == right
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -124,7 +132,7 @@ module Liquid
|
|||||||
if left.respond_to?(right.method_name)
|
if left.respond_to?(right.method_name)
|
||||||
return left.send(right.method_name)
|
return left.send(right.method_name)
|
||||||
else
|
else
|
||||||
return nil
|
return right.to_s == left
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,9 @@ module Liquid
|
|||||||
match = comparison?(markup)
|
match = comparison?(markup)
|
||||||
|
|
||||||
if match
|
if match
|
||||||
left = Expression.parse(match[1].strip, ss, cache)
|
left = Condition.parse(match[1].strip, ss, cache)
|
||||||
operator = match[2].strip
|
operator = match[2].strip
|
||||||
right = Expression.parse(match[3].strip, ss, cache)
|
right = Condition.parse(match[3].strip, ss, cache)
|
||||||
|
|
||||||
return Condition.new(left, operator, right)
|
return Condition.new(left, operator, right)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user