Kaydet (Commit) 2a512a4e authored tarafından Malcolm Tredinnick's avatar Malcolm Tredinnick

Fixed #3749 -- Set the context correctly when using the "filter" template tag.

Thanks, Zak Johnson.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5052 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst 43cd7bb1
...@@ -113,6 +113,7 @@ answer newbie questions, and generally made Django that much better: ...@@ -113,6 +113,7 @@ answer newbie questions, and generally made Django that much better:
Tom Insam Tom Insam
Baurzhan Ismagulov <ibr@radix50.net> Baurzhan Ismagulov <ibr@radix50.net>
jcrasta@gmail.com jcrasta@gmail.com
Zak Johnson <zakj@nox.cx>
Michael Josephson <http://www.sdjournal.com/> Michael Josephson <http://www.sdjournal.com/>
jpellerin@gmail.com jpellerin@gmail.com
junzhang.jn@gmail.com junzhang.jn@gmail.com
......
...@@ -41,7 +41,10 @@ class FilterNode(Node): ...@@ -41,7 +41,10 @@ class FilterNode(Node):
def render(self, context): def render(self, context):
output = self.nodelist.render(context) output = self.nodelist.render(context)
# apply filters # 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): class FirstOfNode(Node):
def __init__(self, vars): def __init__(self, vars):
......
...@@ -259,6 +259,7 @@ class Templates(unittest.TestCase): ...@@ -259,6 +259,7 @@ class Templates(unittest.TestCase):
'filter01': ('{% filter upper %}{% endfilter %}', {}, ''), 'filter01': ('{% filter upper %}{% endfilter %}', {}, ''),
'filter02': ('{% filter upper %}django{% endfilter %}', {}, 'DJANGO'), 'filter02': ('{% filter upper %}django{% endfilter %}', {}, 'DJANGO'),
'filter03': ('{% filter upper|lower %}django{% endfilter %}', {}, 'django'), 'filter03': ('{% filter upper|lower %}django{% endfilter %}', {}, 'django'),
'filter04': ('{% filter cut:remove %}djangospam{% endfilter %}', {'remove': 'spam'}, 'django'),
### FIRSTOF TAG ########################################################### ### FIRSTOF TAG ###########################################################
'firstof01': ('{% firstof a b c %}', {'a':0,'b':0,'c':0}, ''), 'firstof01': ('{% firstof a b c %}', {'a':0,'b':0,'c':0}, ''),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment