<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -20,7 +20,9 @@ module Liquid
   #
   #    {% for item in collection limit:5 offset:10 %}
   #      {{ item.name }}
-  #    {% end %}
+  #    {% end %}             
+  #
+  #  To reverse the for loop simply use {% for item in collection reversed %}
   #
   # == Available variables:
   #
@@ -40,13 +42,14 @@ module Liquid
   # forloop.last:: Returns true if the item is the last item.
   #
   class For &lt; Block                                             
-    Syntax = /(\w+)\s+in\s+(#{VariableSignature}+)/   
+    Syntax = /(\w+)\s+in\s+(#{VariableSignature}+)\s*(reversed)?/   
   
     def initialize(tag_name, markup, tokens)
       if markup =~ Syntax
         @variable_name = $1
         @collection_name = $2
-        @name = &quot;#{$1}-#{$2}&quot;
+        @name = &quot;#{$1}-#{$2}&quot;           
+        @reversed = $3             
         @attributes = {}
         markup.scan(TagAttributes) do |key, value|
           @attributes[key] = value
@@ -80,10 +83,12 @@ module Liquid
       
       return '' if segment.empty?
       
+      segment.reverse! if @reversed
+
       result = []
         
-      length = segment.length
-      
+      length = segment.length            
+            
       # Store our progress through the collection for the continue flag
       context.registers[:for][@name] = from + segment.length
               </diff>
      <filename>lib/liquid/tags/for.rb</filename>
    </modified>
    <modified>
      <diff>@@ -376,6 +376,11 @@ HERE
     assert_template_result('',     '{% if null == true %}?{% endif %}', {})         
   end
   
+  def test_for_reversed
+    assigns = {'array' =&gt; [ 1, 2, 3] }
+    assert_template_result('321','{%for item in array reversed %}{{item}}{%endfor%}',assigns)    
+  end
+  
   def test_ifchanged
     assigns = {'array' =&gt; [ 1, 1, 2, 2, 3, 3] }
     assert_template_result('123','{%for item in array%}{%ifchanged%}{{item}}{% endifchanged %}{%endfor%}',assigns)</diff>
      <filename>test/standard_tag_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8f45647aa37d784163980e9e23e4e515d5ecfd70</id>
    </parent>
  </parents>
  <author>
    <name>Tobias L&#252;tke</name>
    <email>tobi@jadedpixel.com</email>
  </author>
  <url>http://github.com/tobi/liquid/commit/63f9a05223070337021164eabc06059bfafd20d9</url>
  <id>63f9a05223070337021164eabc06059bfafd20d9</id>
  <committed-date>2008-05-08T14:17:41-07:00</committed-date>
  <authored-date>2008-05-08T14:17:41-07:00</authored-date>
  <message>Implemented reversed flag on for loops {% for a in b reversed %}</message>
  <tree>681e5d7e9d1dca228008033dc911c5f3cc6a0b94</tree>
  <committer>
    <name>Tobias L&#252;tke</name>
    <email>tobi@jadedpixel.com</email>
  </committer>
</commit>
