mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -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)
|
||||
end
|
||||
|
||||
def self.parse(markup, ss, cache)
|
||||
@@method_literals[markup] || Expression.parse(markup, ss, cache)
|
||||
end
|
||||
|
||||
attr_reader :attachment, :child_condition
|
||||
attr_accessor :left, :operator, :right
|
||||
|
||||
@@ -112,11 +116,15 @@ module Liquid
|
||||
private
|
||||
|
||||
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 right.respond_to?(left.method_name)
|
||||
return right.send(left.method_name)
|
||||
else
|
||||
return nil
|
||||
return left.to_s == right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -124,7 +132,7 @@ module Liquid
|
||||
if left.respond_to?(right.method_name)
|
||||
return left.send(right.method_name)
|
||||
else
|
||||
return nil
|
||||
return right.to_s == left
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -14,10 +14,9 @@ module Liquid
|
||||
match = comparison?(markup)
|
||||
|
||||
if match
|
||||
left = Expression.parse(match[1].strip, ss, cache)
|
||||
left = Condition.parse(match[1].strip, ss, cache)
|
||||
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)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user