From 9c0568e21ef8acde73e43cd899cf2a74967489b2 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Tue, 26 Sep 2006 07:26:07 +0000 Subject: [PATCH] Fixed #2208 -- Allow empty arguments to be passed to filters. Thanks, mattmcc. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3852 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- AUTHORS | 2 ++ django/template/__init__.py | 2 +- tests/regressiontests/templates/tests.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 9621fd8252..fe2b83ac9f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -104,7 +104,9 @@ answer newbie questions, and generally made Django that much better: Eugene Lazutkin Jeong-Min Lee Christopher Lenz + lerouxb@gmail.com limodou + mattmcc Martin Maney Manuzhai Petar Marić diff --git a/django/template/__init__.py b/django/template/__init__.py index fa75f6c2f5..af8f37a474 100644 --- a/django/template/__init__.py +++ b/django/template/__init__.py @@ -532,7 +532,7 @@ class FilterExpression(object): constant_arg, i18n_arg, var_arg = match.group("constant_arg", "i18n_arg", "var_arg") if i18n_arg: args.append((False, _(i18n_arg.replace(r'\"', '"')))) - elif constant_arg: + elif constant_arg is not None: args.append((False, constant_arg.replace(r'\"', '"'))) elif var_arg: args.append((True, var_arg)) diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 368a46b8fb..e46b715490 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -170,6 +170,9 @@ class Templates(unittest.TestCase): # Escaped backslash using known escape char 'basic-syntax35': (r'{{ var|default_if_none:"foo\now" }}', {"var": None}, r'foo\now'), + # Empty strings can be passed as arguments to filters + 'basic-syntax36': (r'{{ var|join:"" }}', {'var': ['a', 'b', 'c']}, 'abc'), + ### COMMENT TAG ########################################################### 'comment-tag01': ("{% comment %}this is hidden{% endcomment %}hello", {}, "hello"), 'comment-tag02': ("{% comment %}this is hidden{% endcomment %}hello{% comment %}foo{% endcomment %}", {}, "hello"),