[Tutor] #include in DocumentTemplate?
Lance E Sloan
lsloan@umich.edu
Thu, 03 May 2001 11:14:08 -0400
One of the things that frustrates me about learning Python is the lack
of documentation. At least, what I want to know isn't documented or
it's hard to find. Perhaps the reason it's so hard to find is that
such a feature doesn't exist yet.
As I mentioned in one of my previous messages, I've copied the
DocumentTemplate module out of Zope to use with some CGIs that I'm
writing. It works well and I like it, but I'd like to have one DTML
file include another rather than having my program parse several of
them in a row.
Right now, I have code that looks like this:
tmpl = DocumentTemplate.HTMLFile('../templates/header.dtml')
print tmpl(title = 'Specify Your Unvailability Date')
tmpl = DocumentTemplate.HTMLFile('../templates/unavailcal.dtml')
print tmpl(mapping = vars())
tmpl = DocumentTemplate.HTMLFile('../templates/footer.dtml')
print tmpl(year = year)
What I'd like my code to look like is:
tmpl = DocumentTemplate.HTMLFile('../templates/unavailcal.dtml')
print tmpl(mapping = vars())
(Just assume I'm doing the right thing with the arguments to tmpl().)
And unavailcal.dtml would have something like this:
<!--#include header.dtml -->
[body stuff here]
<!--#include footer.dtml -->
Is this possible? I've tried it and it doesn't seem to work. Would I
have to write a new DTML tag/function to do this for me? Has anybody
already done this?
--
Lance E Sloan
Web Services, Univ. of Michigan: Full-service Web and database design,
development, and hosting. Specializing in Perl & Python CGIs.
http://websvcs.itd.umich.edu/ - "Putting U on the Web"