]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Fixed a bug with call_filter not working properly
authorArmin Ronacher <armin.ronacher@active-4.com>
Thu, 4 Jul 2013 14:25:04 +0000 (16:25 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Thu, 4 Jul 2013 14:25:04 +0000 (16:25 +0200)
CHANGES
jinja2/environment.py
jinja2/testsuite/filters.py

diff --git a/CHANGES b/CHANGES
index 3dd68942f9d8e584ea8d00642baebf56b6e845ff..839abe74eb573a8b6ceba1566c7d9863d45cbdd0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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
 -----------
index fad5e237733bfd14223835cdafa3d9699f7df08a..45fabada2eb238504e1c0ccda6e42fd9cf2e707e 100644 (file)
@@ -411,7 +411,7 @@ class Environment(object):
         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 @@ class Environment(object):
             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.
index 5219f767bf239b53f317479effa20d58c280368b..1e1706fd29f3de6aad486e63637e6f6ee56c5118 100644 (file)
@@ -19,6 +19,10 @@ env = Environment()
 
 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'