aboutsummaryrefslogtreecommitdiffstats
path: root/mako/codegen.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-01-16 13:02:51 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-01-16 13:02:51 -0500
commit2879f8bcc02d75d256bf7db97251a8708ef2466e (patch)
treeb64ad6ab41312ce66147818802e218a8057e50e7 /mako/codegen.py
parent3266c0160d9103703400123b81a713db21ccd5be (diff)
downloadexternal_python_mako-2879f8bcc02d75d256bf7db97251a8708ef2466e.tar.gz
external_python_mako-2879f8bcc02d75d256bf7db97251a8708ef2466e.tar.bz2
external_python_mako-2879f8bcc02d75d256bf7db97251a8708ef2466e.zip
- [feature/bug] Can now refer to context variables
within extra arguments to <%block>, <%def>, i.e. <%block name="foo" cache_key="${somekey}">. Filters can also be used in this way, i.e. <%def name="foo()" filter="myfilter"> then template.render(myfilter=some_callable) [ticket:180]
Diffstat (limited to 'mako/codegen.py')
-rw-r--r--mako/codegen.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/mako/codegen.py b/mako/codegen.py
index 0310964..5a7737b 100644
--- a/mako/codegen.py
+++ b/mako/codegen.py
@@ -414,7 +414,7 @@ class _GenerateRenderMethod(object):
# (this is used for the caching decorator)
if limit is not None:
to_write = to_write.intersection(limit)
-
+
if toplevel and getattr(self.compiler, 'has_ns_imports', False):
self.printer.writeline("_import_ns = {}")
self.compiler.has_imports = True
@@ -866,7 +866,6 @@ class _Identifiers(object):
"""tracks the status of identifier names as template code is rendered."""
def __init__(self, node=None, parent=None, nested=False):
-
if parent is not None:
# if we are the branch created in write_namespaces(),
# we don't share any context from the main body().
@@ -1000,6 +999,7 @@ class _Identifiers(object):
if node is self.node:
for ident in node.declared_identifiers():
self.argument_declared.add(ident)
+
for n in node.nodes:
n.accept_visitor(self)
@@ -1016,6 +1016,10 @@ class _Identifiers(object):
"Named block '%s' not allowed inside of <%%call> tag"
% (node.name, ), **node.exception_kwargs)
+ for ident in node.undeclared_identifiers():
+ if ident != 'context' and ident not in self.declared.union(self.locally_declared):
+ self.undeclared.add(ident)
+
if not node.is_anonymous:
self._check_name_exists(self.topleveldefs, node)
self.undeclared.add(node.funcname)