guess I should put this on the site, but you can navigate to all the namespaces present in a particular context, and grab whatever attributes you want. The easiest way for namespaces to pass "configurational" information to each other is via the namespace.attr attribute, which is basically every variable name declared in <%! %> for that namespace's template. So here is one recipe:
from mako.lookup import TemplateLookup
tl = TemplateLookup()
tl.put_string("base.mako",
"""
## base-most template, renders layout etc.
<html>
<head>
% for ns in context.namespaces.values():
% for incl in ns.attr.includes or []:
${incl}
% endfor
% endfor
</head>
<body>
${next.body()}
</body
</html>
"""
)
tl.put_string("library.mako",
"""
## library functions.
<%!
includes = [
'<link rel="stylesheet" type="text/css" href="mystyle.css"/>',
'<script type="text/javascript" src="functions.js"></script>',
]
%>
<%def name="mytag()">
<form>
${caller.body()}
</form>
</%def>
""")
tl.put_string("index.mako",
"""
## calling template.
<%inherit file="base.mako"/>
<%namespace name="foo" file="library.mako"/>
<%foo:mytag>
a form
</%foo:mytag>
""")
print tl.get_template("index.mako").render()
So, as far as making it more of a tag, you can do the same idea, but use a def named includes, this works too:
<head>
% for ns in context.namespaces.values():
% if hasattr(ns, 'includes'):
${ns.includes()}
% endif
% endfor
</head>
<%def name="includes()">
<link rel="stylesheet" type="text/css" href="mystyle.css"/>
<script type="text/javascript" src="functions.js"></script>
</%def>