diff markup/template.py @ 192:cda3bdfc19ed

Expression evaluation now differentiates between undefined variables and variables that are defined but set to `None`.
author cmlenz
date Wed, 23 Aug 2006 17:49:14 +0000
parents 929ef2913b87
children 76129a79458d
line wrap: on
line diff
--- a/markup/template.py
+++ b/markup/template.py
@@ -111,13 +111,14 @@
         """Set a variable in the current scope."""
         self.frames[0][key] = value
 
-    def get(self, key):
+    def get(self, key, default=None):
         """Get a variable's value, starting at the current scope and going
         upward.
         """
         for frame in self.frames:
             if key in frame:
                 return frame[key]
+        return default
     __getitem__ = get
 
     def push(self, data):
Copyright (C) 2012-2017 Edgewall Software