diff --git a/django/core/template.py b/django/core/template.py index b7faebd70c..e727e3e5fa 100644 --- a/django/core/template.py +++ b/django/core/template.py @@ -295,13 +295,14 @@ class FilterParser: if registered_filters[filter_name][1] == True and arg is None: raise TemplateSyntaxError, "Filter '%s' requires an argument" % filter_name if registered_filters[filter_name][1] == False and arg is not None: - raise TemplateSyntaxError, "Filter '%s' should not have an argument" % filter_name + raise TemplateSyntaxError, "Filter '%s' should not have an argument (argument is %r)" % (filter_name, arg) self.filters.append((filter_name, arg)) if self.current is None: break def read_filter(self): self.current_filter_name = self.read_alphanumeric_token() + self.current_filter_arg = None # Have we reached the end? if self.current is None: return (self.current_filter_name, None) diff --git a/tests/othertests/templates.py b/tests/othertests/templates.py index 01b77db401..07b41f5b10 100644 --- a/tests/othertests/templates.py +++ b/tests/othertests/templates.py @@ -92,6 +92,9 @@ TEMPLATE_TESTS = { # Raise TemplateSyntaxError for empty block tags 'basic-syntax28': ("{% %}", {}, template.TemplateSyntaxError), + # Chained filters, with an argument to the first one + 'basic-syntax29': ('{{ var|removetags:"b i"|upper|lower }}', {"var": "Yes"}, "yes"), + ### IF TAG ################################################################ 'if-tag01': ("{% if foo %}yes{% else %}no{% endif %}", {"foo": True}, "yes"), 'if-tag02': ("{% if foo %}yes{% else %}no{% endif %}", {"foo": False}, "no"),