summaryrefslogtreecommitdiff
path: root/jinja2
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2013-07-04 16:25:04 +0200
committerArmin Ronacher <armin.ronacher@active-4.com>2013-07-04 16:25:04 +0200
commit342e88a6c43276e4e5c7e8fd9a83c9f6fee4d6b2 (patch)
tree6fad72af1f85ab05c89792be0537267ebfb76336 /jinja2
parent5ca25297d0cffa171ff6304ff9be6a38834be55d (diff)
downloadjinja2-342e88a6c43276e4e5c7e8fd9a83c9f6fee4d6b2.tar.gz
Fixed a bug with call_filter not working properly
Diffstat (limited to 'jinja2')
-rw-r--r--jinja2/environment.py4
-rw-r--r--jinja2/testsuite/filters.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/jinja2/environment.py b/jinja2/environment.py
index fad5e23..45fabad 100644
--- a/jinja2/environment.py
+++ b/jinja2/environment.py
@@ -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.
diff --git a/jinja2/testsuite/filters.py b/jinja2/testsuite/filters.py
index 5219f76..1e1706f 100644
--- a/jinja2/testsuite/filters.py
+++ b/jinja2/testsuite/filters.py
@@ -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'