Skip to content
Myr

Fixed a bug with call_filter not working properly

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 5ca2529 · Browse files · 3 files+8 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+8 added−2 removed

  • other:+8 added−2 removed

3 files+8 added−2 removed

modified:jinja2/testsuite/filters.py+4 added
17 unmodified lines
181920class FilterTestCase(JinjaTestCase):2122 def test_filter_calling(self):23 rv = env.call_filter('sum', [1, 2, 3])24 self.assert_equal(rv, 6)2526 def test_capitalize(self):27 tmpl = env.from_string('{{ "foo bar"|capitalize }}')28 assert tmpl.render() == 'Foo bar'29
484 unmodified lines
modified:jinja2/environment.py+2 added-2 removed
409 unmodified lines
410 """411 func = self.filters.get(name)412 if func is None:413 raise TemplateRuntimeError('no filter named %r' % name)414 args = list(args or ())414 args = [value] + list(args or ())415 if getattr(func, 'contextfilter', False):416 if context is None:417 raise TemplateRuntimeError('Attempted to invoke context '418 'filter without context')
6 unmodified lines
425 eval_ctx = EvalContext(self)426 args.insert(0, eval_ctx)427 elif getattr(func, 'environmentfilter', False):428 args.insert(0, self)429 return func(value, *args, **(kwargs or {}))429 return func(*args, **(kwargs or {}))430431 def call_test(self, name, value, args=None, kwargs=None):432 """Invokes a test on a value the same way the compiler does it.433
758 unmodified lines
modified:CHANGES+2 added
3 unmodified lines
4Version 2.7.15-------------6(bugfix release)78- Fixed a bug with ``call_filter`` not working properly on environment9 and context filters.1011Version 2.712-----------13(codename Translation, released on May 20th 2013)
294 unmodified lines