[ZPT] Metal and macros
Evan Simpson
evan@digicool.com
Tue, 17 Jul 2001 14:06:30 -0400
Magnus Heino wrote:
> How can I have classes other than PageTemplate defining macros?
I very much want this to be possible, but it's tricky at the moment,
since macros must be TAL programs. There isn't any really clean way to
create TAL programs right now, although they are composed entirely of
simple datatypes. You *could* examine the source, and the data produced
by a simple macro, and replicate it.
Actually, after looking at it some more, I think I'll make a
TALGenerator function that restricted code could import. This would let
you write Script code like this:
from Products.PageTemplates.ZopePageTemplate import TALGenerator
gen = TALGenerator()
gen.emitRawText('<b>')
gen.emitText('Hi, %s, this is HTML quoted!' % context.getName())
gen.emitRawText('</b>')
return gen.getCode()
This Script could then be used directly as a macro.
Cheers,
Evan @ digicool