Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #486 -- Fixed bug in template filter parsing in edge cases, and…

… added unit tests. Thanks, Simon

git-svn-id: http://code.djangoproject.com/svn/django/trunk@634 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 095305cb44e669c9e732eb7c90264795408bb4b8 1 parent e01ef9d
Adrian Holovaty authored September 11, 2005
3  django/core/template.py
@@ -295,13 +295,14 @@ def read_filters(self):
295 295
             if registered_filters[filter_name][1] == True and arg is None:
296 296
                 raise TemplateSyntaxError, "Filter '%s' requires an argument" % filter_name
297 297
             if registered_filters[filter_name][1] == False and arg is not None:
298  
-                raise TemplateSyntaxError, "Filter '%s' should not have an argument" % filter_name
  298
+                raise TemplateSyntaxError, "Filter '%s' should not have an argument (argument is %r)" % (filter_name, arg)
299 299
             self.filters.append((filter_name, arg))
300 300
             if self.current is None:
301 301
                 break
302 302
 
303 303
     def read_filter(self):
304 304
         self.current_filter_name = self.read_alphanumeric_token()
  305
+        self.current_filter_arg = None
305 306
         # Have we reached the end?
306 307
         if self.current is None:
307 308
             return (self.current_filter_name, None)
3  tests/othertests/templates.py
@@ -92,6 +92,9 @@ def method(self):
92 92
     # Raise TemplateSyntaxError for empty block tags
93 93
     'basic-syntax28': ("{% %}", {}, template.TemplateSyntaxError),
94 94
 
  95
+    # Chained filters, with an argument to the first one
  96
+    'basic-syntax29': ('{{ var|removetags:"b i"|upper|lower }}', {"var": "<b><i>Yes</i></b>"}, "yes"),
  97
+
95 98
     ### IF TAG ################################################################
96 99
     'if-tag01': ("{% if foo %}yes{% else %}no{% endif %}", {"foo": True}, "yes"),
97 100
     'if-tag02': ("{% if foo %}yes{% else %}no{% endif %}", {"foo": False}, "no"),

0 notes on commit 095305c

Please sign in to comment.
Something went wrong with that request. Please try again.