Mercurial > genshi > mirror
comparison markup/plugin.py @ 197:b0e1adbf1173 trunk
simplify the `value_of` method exported in the template plugin
author | mgood |
---|---|
date | Thu, 24 Aug 2006 21:02:00 +0000 |
parents | eb0ba1060564 |
children | 58d974683419 |
comparison
equal
deleted
inserted
replaced
196:eb0ba1060564 | 197:b0e1adbf1173 |
---|---|
82 # Some functions for Kid compatibility | 82 # Some functions for Kid compatibility |
83 def defined(name): | 83 def defined(name): |
84 return ctxt.get(name, Undefined) is not Undefined | 84 return ctxt.get(name, Undefined) is not Undefined |
85 ctxt['defined'] = defined | 85 ctxt['defined'] = defined |
86 def value_of(name, default=None): | 86 def value_of(name, default=None): |
87 val = ctxt.get(name, Undefined) | 87 return ctxt.get(name, default) |
88 if val is not Undefined: | |
89 return val | |
90 return default | |
91 ctxt['value_of'] = value_of | 88 ctxt['value_of'] = value_of |
92 | 89 |
93 return template.generate(ctxt) | 90 return template.generate(ctxt) |