[ZPT] ZPT standard in Zope

Magnus Heino magnus.heino@rivermen.se
Thu, 26 Jul 2001 17:20:42 +0100


> I was confused.  Now that I think more about it, I don't have a good

> idea how DTML and ZPT could share a standard template.


I needed this a while ago, and solved it like this:


ZPT-file StandardTemplate:

<html metal:define-macro="master">
<head>
<title tal:content="template/title">The title</title>
</head>
<body>
<span metal:define-slot="content">
<!---dtml--->
</span>
</body>
</html>



Python script standard_html_header:

import string
page = context.StandardTemplate()
return page[:string.find(page, '<!---dtml--->')]



Python script standard_html_footer:

import string
page = context.StandardTemplate()
return page[string.find(page, '<!---dtml--->')+14:]



ZPT-file zpt.html:

<html metal:use-macro="here/StandardTemplate/macros/master">
<head>
<title tal:content="template/title">The title</title>
</head>
<body>
<span metal:fill-slot="content">
foobar
</span>
</body>
</html>



DTML-file dtml.html:

<dtml-var standard_html_header>
foobar
<dtml-var standard_html_footer>



Same result both in dtml and zpt file...

Not the best or fastest of solutions, but it does work ;)

--

  /Magnus Heino