Skip to content

Commit 08d36b0

Browse files
committed
Fixed ComparisonExpression.parse with MethodLiterals
1 parent b5c3d3f commit 08d36b0

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lib/liquid/condition.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def self.parse_expression(parse_context, markup)
5252
@@method_literals[markup] || parse_context.parse_expression(markup)
5353
end
5454

55+
def self.parse(markup, ss, cache)
56+
@@method_literals[markup] || Expression.parse(markup, ss, cache)
57+
end
58+
5559
attr_reader :attachment, :child_condition
5660
attr_accessor :left, :operator, :right
5761

@@ -112,19 +116,23 @@ def inspect
112116
private
113117

114118
def equal_variables(left, right)
119+
if left.is_a?(MethodLiteral) && right.is_a?(MethodLiteral)
120+
return left.to_s == right.to_s
121+
end
122+
115123
if left.is_a?(MethodLiteral)
116124
if right.respond_to?(left.method_name)
117125
return right.send(left.method_name)
118126
else
119-
return nil
127+
return left.to_s == right
120128
end
121129
end
122130

123131
if right.is_a?(MethodLiteral)
124132
if left.respond_to?(right.method_name)
125133
return left.send(right.method_name)
126134
else
127-
return nil
135+
return right.to_s == left
128136
end
129137
end
130138

lib/liquid/expression/comparison_expression.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ def parse(markup, ss, cache)
1414
match = comparison?(markup)
1515

1616
if match
17-
left = Expression.parse(match[1].strip, ss, cache)
17+
left = Condition.parse(match[1].strip, ss, cache)
1818
operator = match[2].strip
19-
right = Expression.parse(match[3].strip, ss, cache)
20-
19+
right = Condition.parse(match[3].strip, ss, cache)
2120
return Condition.new(left, operator, right)
2221
end
2322

0 commit comments

Comments
 (0)