[ZPT] ZPT standard in Zope

Peter Bengtsson mail@peterbe.com
Fri, 27 Jul 2001 17:42:51 +0200


Could you not pleeease submit this as a recepie at ZopeLabs.com (excellent
site!)

----- Original Message -----
From: "Magnus Heino" <magnus.heino@rivermen.se>
To: "Evan Simpson" <evan@digicool.com>
Cc: "Peter Bengtsson" <mail@peterbe.com>; <zpt@zope.org>
Sent: Thursday, July 26, 2001 6:20 PM
Subject: Re: [ZPT] ZPT standard in Zope


>
> > 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