mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 10:52:48 -07:00
Strict parse conditions in reverse order
This commit is contained in:
+10
-3
@@ -84,14 +84,21 @@ module Liquid
|
|||||||
def strict_parse(markup)
|
def strict_parse(markup)
|
||||||
p = Parser.new(markup)
|
p = Parser.new(markup)
|
||||||
|
|
||||||
condition = parse_comparison(p)
|
conditions = [parse_comparison(p)]
|
||||||
|
|
||||||
while op = (p.id?('and'.freeze) || p.id?('or'.freeze))
|
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)
|
new_cond.send(op, condition)
|
||||||
condition = new_cond
|
condition = new_cond
|
||||||
end
|
end
|
||||||
p.consume(:end_of_string)
|
|
||||||
|
|
||||||
condition
|
condition
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user