mirror of
https://github.com/kemko/liquid.git
synced 2026-01-07 02:35:40 +03:00
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:
@@ -1,6 +1,6 @@
|
|||||||
module Liquid
|
module Liquid
|
||||||
class TableRow < Block
|
class TableRow < Block
|
||||||
Syntax = /(\w+)\s+in\s+(#{VariableSignature}+)/
|
Syntax = /(\w+)\s+in\s+(#{QuotedFragment}+)/
|
||||||
|
|
||||||
def initialize(tag_name, markup, tokens)
|
def initialize(tag_name, markup, tokens)
|
||||||
if markup =~ Syntax
|
if markup =~ Syntax
|
||||||
|
|||||||
@@ -26,4 +26,11 @@ class HtmlTagTest < Test::Unit::TestCase
|
|||||||
'{% tablerow n in numbers cols:2%}{{tablerowloop.col}}{% endtablerow %}',
|
'{% tablerow n in numbers cols:2%}{{tablerowloop.col}}{% endtablerow %}',
|
||||||
'numbers' => [1,2,3,4,5,6])
|
'numbers' => [1,2,3,4,5,6])
|
||||||
end
|
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
|
end # HtmlTagTest
|
||||||
|
|||||||
Reference in New Issue
Block a user