Implemented reversed flag on for loops {% for a in b reversed %}

This commit is contained in:
Tobias Lütke
2008-05-08 17:17:41 -04:00
parent 8f45647aa3
commit 63f9a05223
2 changed files with 15 additions and 5 deletions

View File

@@ -376,6 +376,11 @@ HERE
assert_template_result('', '{% if null == true %}?{% endif %}', {})
end
def test_for_reversed
assigns = {'array' => [ 1, 2, 3] }
assert_template_result('321','{%for item in array reversed %}{{item}}{%endfor%}',assigns)
end
def test_ifchanged
assigns = {'array' => [ 1, 1, 2, 2, 3, 3] }
assert_template_result('123','{%for item in array%}{%ifchanged%}{{item}}{% endifchanged %}{%endfor%}',assigns)