public
Rubygem
Description: Liquid markup language. Save, customer facing template language for flexible web apps.
Homepage: http://www.liquidmarkup.org
Clone URL: git://github.com/tobi/liquid.git
Click here to lend your support to: liquid and make a donation at www.pledgie.com !
filtered variables in for loops
jamesmacaulay (author)
Fri Oct 24 11:50:59 -0700 2008
commit  3d8efe04a743d6fb4c3bc8d198f630f9896b853e
tree    424ebb46e90d7f00e5123369252f9188829ae3e6
parent  edf7b5577b5aa60567335dff1e6bc1d2568eea68
...
42
43
44
45
 
46
47
48
...
42
43
44
 
45
46
47
48
0
@@ -42,7 +42,7 @@ module Liquid
0
   # forloop.last:: Returns true if the item is the last item.
0
   #
0
   class For < Block                                             
0
-    Syntax = /(\w+)\s+in\s+(#{VariableSignature}+)\s*(reversed)?/   
0
+    Syntax = /(\w+)\s+in\s+(#{Expression}+)\s*(reversed)?/   
0
   
0
     def initialize(tag_name, markup, tokens)
0
       if markup =~ Syntax
...
99
100
101
 
 
 
 
102
103
104
...
99
100
101
102
103
104
105
106
107
108
0
@@ -99,6 +99,10 @@ HERE
0
     assert_template_result('+--', '{%for item in array%}{% if forloop.first %}+{% else %}-{% endif %}{%endfor%}', assigns)
0
   end
0
   
0
+  def test_for_with_filtered_expressions
0
+    assert_template_result('abc','{% for letter in letters|sort %}{{ letter }}{% endfor %}', 'letters' => %w{c b a})
0
+  end
0
+  
0
   def test_limiting
0
     assigns = {'array' => [1,2,3,4,5,6,7,8,9,0]}
0
     assert_template_result('12','{%for i in array limit:2 %}{{ i }}{%endfor%}',assigns)

Comments