[ZPT] Can macros be employed in Page Templates outside of Zope?

Hamish Lawson hamish_lawson@yahoo.co.uk
Wed, 29 Aug 2001 17:54:16 -0000


Is it possible to employ macros when using PageTemplates outside of 
Zope?

I have the three files below: standard_page.html defines a 
macro 'master'; page.html is intended to use this macro; and 
render_page.py creates the PageTemplate objects and asks the template 
for page.html to render itself, passing it the template for 
standard_page.html. Originally I tried to refer to standard_page.html 
from within page.html as 'container/standard_page.html', but when 
that didn't work, I tried passing a template object as an option. 
However I still get an error saying that 'master' can't be found.

Hamish Lawson


::::::::::::::
standard_page.html
::::::::::::::
<html metal:define-macro="master">

<p>Outer page</p>

<div metal:define-slot="main">
</div>

</html>

::::::::::::::
page.html
::::::::::::::
<html metal:use-macro="options/standard_page/macros/master">
<div metal:fill-slot="main">
<p>Inner page</p>
</div>
</html>

::::::::::::::
render_page.py
::::::::::::::
from PageTemplates.PageTemplate import PageTemplate

pt = PageTemplate()
template_file = open('page.html')
pt.write(template_file.read())
template_file.close()

standard_page = PageTemplate()
template_file = open('standard_page.html')
standard_page.write(template_file.read())
template_file.close()

print pt(standard_page=standard_page)