From 075341d01c216f107b1bd815e84dd9846aade5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=BCtke?= Date: Mon, 6 Apr 2009 08:37:39 -0600 Subject: [PATCH] Fix for parsing spaces in fragments --- lib/liquid.rb | 3 ++- test/assign_test.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/liquid.rb b/lib/liquid.rb index a58575a..1e970d2 100644 --- a/lib/liquid.rb +++ b/lib/liquid.rb @@ -33,7 +33,8 @@ module Liquid VariableStart = /\{\{/ VariableEnd = /\}\}/ VariableIncompleteEnd = /\}\}?/ - QuotedFragment = /"[^"]+"|'[^']+'|[^\s,|]+/ + QuotedString = /"[^"]+"|'[^']+'/ + QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/ TagAttributes = /(\w+)\s*\:\s*(#{QuotedFragment})/ AnyStartingTag = /\{\{|\{\%/ PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/ diff --git a/test/assign_test.rb b/test/assign_test.rb index 9bf6f2f..95e9755 100644 --- a/test/assign_test.rb +++ b/test/assign_test.rb @@ -4,7 +4,8 @@ class AssignTest < Test::Unit::TestCase include Liquid def test_assigned_variable - assert_template_result('.foo.','{% assign foo = values %}.{{ foo }}.', 'values' => %w{foo bar baz}) + assert_template_result('.foo.','{% assign foo = values %}.{{ foo[0] }}.', 'values' => %w{foo bar baz}) + assert_template_result('.bar.','{% assign foo = values %}.{{ foo[1] }}.', 'values' => %w{foo bar baz}) end end \ No newline at end of file