- fixed/improved "caller" semantics so that undefined caller is "UNDEFINED",
propigates __nonzero__ method so it evaulates to False if not present,
True otherwise. this way you can say % if caller:\n ${caller.body()}\n% endif
diff --git a/CHANGES b/CHANGES
index c40b6e5..6a6a1cf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,9 @@
- fix to variable scoping for identifiers only referenced within functions
- added a path normalization step to lookup so URIs like "/foo/bar/../etc/../foo"
pre-process the ".." tokens before checking the filesystem
+- fixed/improved "caller" semantics so that undefined caller is "UNDEFINED",
+propigates __nonzero__ method so it evaulates to False if not present,
+True otherwise. this way you can say % if caller:\n ${caller.body()}\n% endif
0.1.3
- ***Small Syntax Change*** - the single line comment character is now
diff --git a/lib/mako/runtime.py b/lib/mako/runtime.py
index e6e640b..5f4e419 100644
--- a/lib/mako/runtime.py
+++ b/lib/mako/runtime.py
@@ -22,7 +22,7 @@
data['capture'] = lambda x, *args, **kwargs: capture(self, x, *args, **kwargs)
# "caller" stack used by def calls with content
- self.caller_stack = [Undefined]
+ self.caller_stack = [UNDEFINED]
data['caller'] = _StackFacade(self, None)
lookup = property(lambda self:self._with_template.lookup)
kwargs = property(lambda self:self._kwargs.copy())
@@ -74,6 +74,8 @@
def __init__(self, context, local):
self.__stack = context.caller_stack
self.__local = local
+ def __nonzero__(self):
+ return self._get_actual_caller() and True or False
def _get_actual_caller(self):
caller = self.__stack[-1]
if caller is None: