From 043d816460f56af2983a89af9129acf54d264643 Mon Sep 17 00:00:00 2001 From: Dennis Theisen Date: Wed, 22 Feb 2012 12:45:38 -0500 Subject: [PATCH] Fix tablerow block to work with collection names in quoted syntax. * Allows e.g. {% tablerow product in collections['frontpage'] %} instead of only collections.frontpage --- lib/liquid/htmltags.rb | 2 +- test/liquid/tags/html_tag_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/liquid/htmltags.rb b/lib/liquid/htmltags.rb index f283b94..dfb8c76 100644 --- a/lib/liquid/htmltags.rb +++ b/lib/liquid/htmltags.rb @@ -1,6 +1,6 @@ module Liquid class TableRow < Block - Syntax = /(\w+)\s+in\s+(#{VariableSignature}+)/ + Syntax = /(\w+)\s+in\s+(#{QuotedFragment}+)/ def initialize(tag_name, markup, tokens) if markup =~ Syntax diff --git a/test/liquid/tags/html_tag_test.rb b/test/liquid/tags/html_tag_test.rb index 47d2ea3..c3ba1bc 100644 --- a/test/liquid/tags/html_tag_test.rb +++ b/test/liquid/tags/html_tag_test.rb @@ -26,4 +26,11 @@ class HtmlTagTest < Test::Unit::TestCase '{% tablerow n in numbers cols:2%}{{tablerowloop.col}}{% endtablerow %}', 'numbers' => [1,2,3,4,5,6]) end + + def test_quoted_fragment + assert_template_result("\n 1 2 3 \n 4 5 6 \n", + "{% tablerow n in collections['frontpage'] cols:3%} {{n}} {% endtablerow %}", + 'collections' => {'frontpage' => [1,2,3,4,5,6]}) + + end end # HtmlTagTest