[ZPT] Using METAL to access a macro outside PT rendering
Evan Simpson
evan@zope.com
Mon, 17 Dec 2001 22:22:07 -0500
Francis Potter wrote:
> But this seems very indirect. Is there a simpler way, maybe one which
> doesn't involve actually building a separate PageTemplate object? What I
> really want is to be able to say something like:
>
> x.extractMacro("test")
You just want the HTML snippet? If 'x' is your Page Template, you can
write:
x.macros['test']
...and you'll get a data structure that you can extract the text from
fairly easily. Be warned, any TAL or METAL in the macro will complicate
this data structure a lot. Also, this data structure isn't likely to
stay the same in future versions. I hope to have a supported interface
for creating and manipulating macros in a version or two, though.
Cheers,
Evan @ Zope