diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2008-01-05 00:03:12 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2008-01-05 00:03:12 +0000 |
| commit | 3d52ce730f72437645da3107fac8d29b3408ae61 (patch) | |
| tree | 9da027aa08cf0fb8750f4a790e6ac135168c0954 | |
| parent | 6929c0d4d1d3b4611db0f8852772e1c2b87f8245 (diff) | |
Reverted 'regroup' template tag changes from [6956], as they caused bug #6271, which affects one of my sites. I don't have time to inspect the #6271 patch, so I'm reverting this change in the interim, to fix the bug immediately.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6996 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/template/defaulttags.py | 16 | ||||
| -rw-r--r-- | tests/regressiontests/templates/tests.py | 10 |
2 files changed, 9 insertions, 17 deletions
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 726a37012b..e5a8e6620b 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -924,18 +924,20 @@ def regroup(parser, token): {% regroup people|dictsort:"gender" by gender as grouped %} """ - bits = token.contents.split() - if len(bits) != 6: + firstbits = token.contents.split(None, 3) + if len(firstbits) != 4: raise TemplateSyntaxError, "'regroup' tag takes five arguments" - target = parser.compile_filter(bits[1]) - if bits[2] != 'by': + target = parser.compile_filter(firstbits[1]) + if firstbits[2] != 'by': raise TemplateSyntaxError("second argument to 'regroup' tag must be 'by'") - if bits[4] != 'as': + lastbits_reversed = firstbits[3][::-1].split(None, 2) + if lastbits_reversed[1][::-1] != 'as': raise TemplateSyntaxError("next-to-last argument to 'regroup' tag must" " be 'as'") - expression = parser.compile_filter(bits[3]) - var_name = bits[5] + expression = parser.compile_filter(lastbits_reversed[2][::-1]) + + var_name = lastbits_reversed[0][::-1] return RegroupNode(target, expression, var_name) regroup = register.tag(regroup) diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index ef8fd43292..9e9033f975 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -809,16 +809,6 @@ class Templates(unittest.TestCase): '{% endfor %},' + \ '{% endfor %}', {}, ''), - - # Test syntax. - 'regroup03': ('{% regroup data by bar as %}', {}, - template.TemplateSyntaxError), - 'regroup04': ('{% regroup data by bar thisaintright grouped %}', {}, - template.TemplateSyntaxError), - 'regroup05': ('{% regroup data thisaintright bar as grouped %}', {}, - template.TemplateSyntaxError), - 'regroup06': ('{% regroup data by bar as grouped toomanyargs %}', {}, - template.TemplateSyntaxError), ### TEMPLATETAG TAG ####################################################### 'templatetag01': ('{% templatetag openblock %}', {}, '{%'), |
