From 335b87a84695854f3af03ada3131c55fc59d4a31 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 21 Sep 2008 17:08:48 +0200 Subject: [PATCH] Fixed a bug in constant folding of keyword arguments to filter calls. Thanks noskolo. --HG-- branch : trunk --- jinja2/nodes.py | 3 +++ tests/test_old_bugs.py | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/test_old_bugs.py diff --git a/jinja2/nodes.py b/jinja2/nodes.py index 034becf..ec2ed3e 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 0000000..08db225 --- /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' + -- 2.26.2