Strict parse conditions in reverse order

This commit is contained in:
Justin Li
2015-05-19 11:51:01 -04:00
parent b4e5017c79
commit a9c7df931f
+10 -3
View File
@@ -84,14 +84,21 @@ module Liquid
def strict_parse(markup)
p = Parser.new(markup)
condition = parse_comparison(p)
conditions = [parse_comparison(p)]
while op = (p.id?('and'.freeze) || p.id?('or'.freeze))
new_cond = parse_comparison(p)
conditions << op << parse_comparison(p)
end
p.consume(:end_of_string)
condition = conditions.pop
until conditions.empty?
op = conditions.pop
new_cond = conditions.pop
new_cond.send(op, condition)
condition = new_cond
end
p.consume(:end_of_string)
condition
end