mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
fix if tag parsing with expressions starting with and/or
This commit is contained in:
@@ -14,7 +14,7 @@ module Liquid
|
||||
class If < Block
|
||||
SyntaxHelp = "Syntax Error in tag 'if' - Valid syntax: if [expression]"
|
||||
Syntax = /(#{QuotedFragment})\s*([=!<>a-z_]+)?\s*(#{QuotedFragment})?/
|
||||
ExpressionsAndOperators = /(?:and|or|(?:\s*(?!\b(?:and|or)\b)(?:#{QuotedFragment}|\S+)\s*)+)/
|
||||
ExpressionsAndOperators = /(?:\b(?:and|or)\b|(?:\s*(?!\b(?:and|or)\b)(?:#{QuotedFragment}|\S+)\s*)+)/
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
|
||||
|
||||
@@ -44,6 +44,20 @@ class IfElseTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_comparison_of_expressions_starting_with_and_or_or
|
||||
assigns = {'order' => {'items_count' => 0}, 'android' => {'name' => 'Roy'}}
|
||||
assert_nothing_raised do
|
||||
assert_template_result( "YES",
|
||||
"{% if android.name == 'Roy' %}YES{% endif %}",
|
||||
assigns)
|
||||
end
|
||||
assert_nothing_raised do
|
||||
assert_template_result( "YES",
|
||||
"{% if order.items_count == 0 %}YES{% endif %}",
|
||||
assigns)
|
||||
end
|
||||
end
|
||||
|
||||
def test_if_and
|
||||
assert_template_result(' YES ','{% if true and true %} YES {% endif %}')
|
||||
assert_template_result('','{% if false and true %} YES {% endif %}')
|
||||
|
||||
Reference in New Issue
Block a user