func = self.filters.get(name)
if func is None:
raise TemplateRuntimeError('no filter named %r' % name)
- args = list(args or ())
+ args = [value] + list(args or ())
if getattr(func, 'contextfilter', False):
if context is None:
raise TemplateRuntimeError('Attempted to invoke context '
args.insert(0, eval_ctx)
elif getattr(func, 'environmentfilter', False):
args.insert(0, self)
- return func(value, *args, **(kwargs or {}))
+ return func(*args, **(kwargs or {}))
def call_test(self, name, value, args=None, kwargs=None):
"""Invokes a test on a value the same way the compiler does it.
class FilterTestCase(JinjaTestCase):
+ def test_filter_calling(self):
+ rv = env.call_filter('sum', [1, 2, 3])
+ self.assert_equal(rv, 6)
+
def test_capitalize(self):
tmpl = env.from_string('{{ "foo bar"|capitalize }}')
assert tmpl.render() == 'Foo bar'