diff markup/template.py @ 165:4ed68a904235

Fix handling of keyword arguments in `py:def` directive. Thanks to Christian Boos for reporting the problem and providing the basic patch for this change.
author cmlenz
date Thu, 17 Aug 2006 14:02:58 +0000
parents a25f9fc5787d
children 718cba809cea
line wrap: on
line diff
--- a/markup/template.py
+++ b/markup/template.py
@@ -306,7 +306,8 @@
             for arg in ast.args:
                 if isinstance(arg, compiler.ast.Keyword):
                     self.args.append(arg.name)
-                    self.defaults[arg.name] = arg.expr.value
+                    self.defaults[arg.name] = Expression(arg.expr, filename,
+                                                         lineno)
                 else:
                     self.args.append(arg.name)
         else:
@@ -322,7 +323,11 @@
                 if args:
                     scope[name] = args.pop(0)
                 else:
-                    scope[name] = kwargs.pop(name, self.defaults.get(name))
+                    if name in kwargs:
+                        val = kwargs.pop(name)
+                    else:
+                        val = self.defaults.get(name).evaluate(ctxt)
+                    scope[name] = val
             ctxt.push(scope)
             for event in _apply_directives(stream, ctxt, directives):
                 yield event
Copyright (C) 2012-2017 Edgewall Software