Fixed some parse errors thanks to Daniel Sheppard [Closes #6]

This commit is contained in:
Tobias Lütke 2008-12-22 11:47:26 -05:00
parent 7b9b5f31fb
commit 88309cf415
3 changed files with 12 additions and 4 deletions

View File

@ -33,7 +33,8 @@ module Liquid
VariableStart = /\{\{/
VariableEnd = /\}\}/
VariableIncompleteEnd = /\}\}?/
QuotedFragment = /"[^"]+"|'[^']+'|[^\s,\|]+/
QuotedString = /"[^"]+"|'[^']+'/
QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/
StrictQuotedFragment = /"[^"]+"|'[^']+'|[^\s,\|,\:,\,]+/
FirstFilterArgument = /#{FilterArgumentSeparator}(?:#{StrictQuotedFragment})/
OtherFilterArgument = /#{ArgumentSeparator}(?:#{StrictQuotedFragment})/

View File

@ -13,8 +13,8 @@ module Liquid
# <div class="green"> Item five</div>
#
class Cycle < Tag
SimpleSyntax = /#{Expression}/
NamedSyntax = /(#{Expression})\s*\:\s*(.*)/
SimpleSyntax = /^#{Expression}/
NamedSyntax = /^(#{Expression})\s*\:\s*(.*)/
def initialize(tag_name, markup, tokens)
case markup
@ -27,7 +27,6 @@ module Liquid
else
raise SyntaxError.new("Syntax Error in 'cycle' - Valid syntax: cycle [name :] var [, var2, var3 ...]")
end
super
end

View File

@ -212,6 +212,11 @@ HERE
assert_template_result('a-b:1 a-b:2','a-b:{{a-b}} {%assign a-b = 2 %}a-b:{{a-b}}',assigns)
end
def test_assign_with_colon_and_spaces
assigns = {'var' => {'a:b c' => {'paged' => '1' }}}
assert_template_result('var2: 1','{%assign var2 = var["a:b c"].paged %}var2: {{var2}}',assigns)
end
def test_capture
assigns = {'var' => 'content' }
@ -348,6 +353,9 @@ HERE
assert_template_result('one two','{%cycle "one", "two"%} {%cycle "one", "two"%}')
assert_template_result('one two one','{%cycle "one", "two"%} {%cycle "one", "two"%} {%cycle "one", "two"%}')
assert_template_result('text-align: left text-align: right','{%cycle "text-align: left", "text-align: right" %} {%cycle "text-align: left", "text-align: right"%}')
end
def test_multiple_cycles