include file containing namespaces

31 views
Skip to first unread message

binadam

unread,
Feb 14, 2013, 4:51:11 PM2/14/13
to mako-d...@googlegroups.com
I have a file called "namespaces.mako":
<%namespace name="a" file="a:templates/base.html" />
<%namespace name="b" file="b:templates/base.html" />

Now I want to be able to use these namespaces in different files, as:
<%include file="namespaces.mako" />
${a.foo()}

But this doesn't work. What's the correct way to do this?
Thanks.

binadam

unread,
Feb 14, 2013, 4:53:49 PM2/14/13
to mako-d...@googlegroups.com
Guess I should mention the error:
AttributeError: 'Undefined' object has no attribute 'foo'

Michael Bayer

unread,
Feb 15, 2013, 11:01:50 AM2/15/13
to mako-d...@googlegroups.com
that would be something like a "static include" but that's not something Mako has.

There's really not a built in function for this, the best you could do would be something like building a custom preprocessor that adds in <%namespace> tags, if you wanted to do that you could use the "preprocessor" argument to Template / TemplateLookup.


Reply all
Reply to author
Forward
0 new messages