diff --git a/AUTHORS b/AUTHORS index 9f36d49d10..cf5ce947d6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -113,6 +113,7 @@ answer newbie questions, and generally made Django that much better: Tom Insam Baurzhan Ismagulov jcrasta@gmail.com + Zak Johnson Michael Josephson jpellerin@gmail.com junzhang.jn@gmail.com diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index ef57aa2449..d997d20077 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -41,7 +41,10 @@ class FilterNode(Node): def render(self, context): output = self.nodelist.render(context) # apply filters - return self.filter_expr.resolve(Context({'var': output})) + context.update({'var': output}) + filtered = self.filter_expr.resolve(context) + context.pop() + return filtered class FirstOfNode(Node): def __init__(self, vars): diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 54fd9cf253..93fb1ecb4d 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -259,6 +259,7 @@ class Templates(unittest.TestCase): 'filter01': ('{% filter upper %}{% endfilter %}', {}, ''), 'filter02': ('{% filter upper %}django{% endfilter %}', {}, 'DJANGO'), 'filter03': ('{% filter upper|lower %}django{% endfilter %}', {}, 'django'), + 'filter04': ('{% filter cut:remove %}djangospam{% endfilter %}', {'remove': 'spam'}, 'django'), ### FIRSTOF TAG ########################################################### 'firstof01': ('{% firstof a b c %}', {'a':0,'b':0,'c':0}, ''),