Fix tablerow block to work with collection names in quoted syntax.

* Allows e.g. {% tablerow product in collections['frontpage'] %} instead of only collections.frontpage
This commit is contained in:
Dennis Theisen
2012-02-22 12:45:38 -05:00
parent d8b416187a
commit 043d816460
2 changed files with 8 additions and 1 deletions

View File

@@ -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

View File

@@ -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("<tr class=\"row1\">\n<td class=\"col1\"> 1 </td><td class=\"col2\"> 2 </td><td class=\"col3\"> 3 </td></tr>\n<tr class=\"row2\"><td class=\"col1\"> 4 </td><td class=\"col2\"> 5 </td><td class=\"col3\"> 6 </td></tr>\n",
"{% tablerow n in collections['frontpage'] cols:3%} {{n}} {% endtablerow %}",
'collections' => {'frontpage' => [1,2,3,4,5,6]})
end
end # HtmlTagTest