Fixed a bug in constant folding of keyword arguments to filter calls. Thanks noskolo.
authorArmin Ronacher <armin.ronacher@active-4.com>
Sun, 21 Sep 2008 15:08:48 +0000 (17:08 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Sun, 21 Sep 2008 15:08:48 +0000 (17:08 +0200)
--HG--
branch : trunk

jinja2/nodes.py
tests/test_old_bugs.py [new file with mode: 0644]

index 034becf60c07e9ba18bbc2465569a8b72484470a..ec2ed3e68ea318101615d9d0c83af2f6e4c9c709 100644 (file)
@@ -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 (file)
index 0000000..08db225
--- /dev/null
@@ -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'
+