Ticket #3749: FilterNode.2.patch

File FilterNode.2.patch, 1.3 KB (added by Zak Johnson <zakj@…>, 18 years ago)

patch with regression test

  • django/template/defaulttags.py

     
    4141    def render(self, context):
    4242        output = self.nodelist.render(context)
    4343        # apply filters
    44         return self.filter_expr.resolve(Context({'var': output}))
     44        context.update({'var': output})
     45        filtered = self.filter_expr.resolve(context)
     46        context.pop()
     47        return filtered
    4548
    4649class FirstOfNode(Node):
    4750    def __init__(self, vars):
  • tests/regressiontests/templates/tests.py

     
    259259            'filter01': ('{% filter upper %}{% endfilter %}', {}, ''),
    260260            'filter02': ('{% filter upper %}django{% endfilter %}', {}, 'DJANGO'),
    261261            'filter03': ('{% filter upper|lower %}django{% endfilter %}', {}, 'django'),
     262            'filter04': ('{% filter cut:remove %}djangospam{% endfilter %}', {'remove': 'spam'}, 'django'),
    262263
    263264            ### FIRSTOF TAG ###########################################################
    264265            'firstof01': ('{% firstof a b c %}', {'a':0,'b':0,'c':0}, ''),
Back to Top