summaryrefslogtreecommitdiff
path: root/django/template/__init__.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2006-07-04 03:21:44 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2006-07-04 03:21:44 +0000
commit6b383afd39ee2e493a308cb5c70dfa880d27edf6 (patch)
tree85068dd1c4626d68da862814bd5d2cfd804098c8 /django/template/__init__.py
parent009f224e5799ffd963ce325fd1c1181bfab3dc14 (diff)
Fixes #1338, Refs #1400, #2237 -- Modified variable resolution to allow template 'if' statements to work if TEMPLATE_STRING_IF_INVALID is set. Modified unit tests to force the use of this variable, so that returning '' isn't confused with an actual failure.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3268 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/template/__init__.py')
-rw-r--r--django/template/__init__.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/django/template/__init__.py b/django/template/__init__.py
index 08f433fec9..993de7304e 100644
--- a/django/template/__init__.py
+++ b/django/template/__init__.py
@@ -318,7 +318,7 @@ class Parser(object):
self.tags.update(lib.tags)
self.filters.update(lib.filters)
- def compile_filter(self,token):
+ def compile_filter(self, token):
"Convenient wrapper for FilterExpression"
return FilterExpression(token, self)
@@ -543,11 +543,14 @@ class FilterExpression(object):
raise TemplateSyntaxError, "Could not parse the remainder: %s" % token[upto:]
self.var, self.filters = var, filters
- def resolve(self, context):
+ def resolve(self, context, ignore_failures=False):
try:
obj = resolve_variable(self.var, context)
except VariableDoesNotExist:
- obj = settings.TEMPLATE_STRING_IF_INVALID
+ if ignore_failures:
+ return None
+ else:
+ return settings.TEMPLATE_STRING_IF_INVALID
for func, args in self.filters:
arg_vals = []
for lookup, arg in args: