From ddfc7c2530197112fb105b6dd237574bc2fd6b49 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Mon, 30 Apr 2012 21:01:06 +0200 Subject: [PATCH] Fixed #4746 -- Allowed spaces around filter separator. --- django/template/base.py | 2 +- tests/regressiontests/templates/tests.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/django/template/base.py b/django/template/base.py index 16b0934aca..ab44bfb0b1 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -486,7 +486,7 @@ constant_string = constant_string.replace("\n", "") filter_raw_string = r""" ^(?P%(constant)s)| ^(?P[%(var_chars)s]+|%(num)s)| - (?:%(filter_sep)s + (?:\s*%(filter_sep)s\s* (?P\w+) (?:%(arg_sep)s (?: diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 7de27a08a9..d4ef2aa574 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -634,11 +634,11 @@ class Templates(unittest.TestCase): # Chained filters 'filter-syntax02': ("{{ var|upper|lower }}", {"var": "Django is the greatest!"}, "django is the greatest!"), - # Raise TemplateSyntaxError for space between a variable and filter pipe - 'filter-syntax03': ("{{ var |upper }}", {}, template.TemplateSyntaxError), + # Allow spaces before the filter pipe + 'filter-syntax03': ("{{ var |upper }}", {"var": "Django is the greatest!"}, "DJANGO IS THE GREATEST!"), - # Raise TemplateSyntaxError for space after a filter pipe - 'filter-syntax04': ("{{ var| upper }}", {}, template.TemplateSyntaxError), + # Allow spaces after the filter pipe + 'filter-syntax04': ("{{ var| upper }}", {"var": "Django is the greatest!"}, "DJANGO IS THE GREATEST!"), # Raise TemplateSyntaxError for a nonexistent filter 'filter-syntax05': ("{{ var|does_not_exist }}", {}, template.TemplateSyntaxError),