Permalink
Browse files

Fixed a bug with call_filter not working properly

  • Loading branch information...
1 parent 5ca2529 commit 342e88a6c43276e4e5c7e8fd9a83c9f6fee4d6b2 @mitsuhiko mitsuhiko committed Jul 4, 2013
Showing with 8 additions and 2 deletions.
  1. +2 −0 CHANGES
  2. +2 −2 jinja2/environment.py
  3. +4 −0 jinja2/testsuite/filters.py
View
@@ -5,6 +5,8 @@ Version 2.7.1
-------------
(bugfix release)
+- Fixed a bug with ``call_filter`` not working properly on environment
+ and context filters.
Version 2.7
-----------
View
@@ -411,7 +411,7 @@ def call_filter(self, name, value, args=None, kwargs=None,
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 '
@@ -426,7 +426,7 @@ def call_filter(self, name, value, args=None, kwargs=None,
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.
@@ -19,6 +19,10 @@
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'

0 comments on commit 342e88a

Please sign in to comment.