From: Armin Ronacher Date: Sun, 21 Sep 2008 15:08:48 +0000 (+0200) Subject: Fixed a bug in constant folding of keyword arguments to filter calls. Thanks noskolo. X-Git-Tag: 2.1~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=335b87a84695854f3af03ada3131c55fc59d4a31;p=thirdparty%2Fjinja.git Fixed a bug in constant folding of keyword arguments to filter calls. Thanks noskolo. --HG-- branch : trunk --- diff --git a/jinja2/nodes.py b/jinja2/nodes.py index 034becf6..ec2ed3e6 100644 --- a/jinja2/nodes.py +++ b/jinja2/nodes.py @@ -464,6 +464,9 @@ class Keyword(Helper): """A key, value pair for keyword arguments where key is a string.""" fields = ('key', 'value') + def as_const(self): + return self.key, self.value.as_const() + class CondExpr(Expr): """A conditional expression (inline if expression). (``{{ diff --git a/tests/test_old_bugs.py b/tests/test_old_bugs.py new file mode 100644 index 00000000..08db225d --- /dev/null +++ b/tests/test_old_bugs.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +""" + Tests for old bugs + ~~~~~~~~~~~~~~~~~~ + + Unittest that test situations caused by various older bugs. + + :copyright: Copyright 2008 by Armin Ronacher. + :license: BSD. +""" +from jinja2 import Environment + +def test_keyword_folding(): + env = Environment() + env.filters['testing'] = lambda value, some: value + some + assert env.from_string("{{ 'test'|testing(some='stuff') }}") \ + .render() == 'teststuff' +