[z3-five] (re)using zpt macros from view page templates
Philipp von Weitershausen
philipp at weitershausen.de
Mon Jan 29 23:45:31 CET 2007
Chris Withers wrote:
> Andreas Jung wrote:
>>> I have a page template that's being used for Five view. I now want to
>>> re-use part of that template as a zpt macro in another Five view.
>>>
>>> How should I go about doing this?
>> By registering the template with the macros as views?
>
> Is that the canonical way? it seems pretty heavyweight in terms of
> instantiating a whole view, with request and all, just to get a macro...
>
> How about:
>
> my_macro.pt
> -----------
> <html metal:define-macro="template">
> ...etc...
> <metal:x define-slot="foo"/>
> ...etc...
> </html>
<browser:page name="mymacro" template="my_macro.pt" ... />
> myview.pt
> ---------
> <html metal:use-macro="view/getMacro">
use-macro="context/@@mymacro/template"
> <div fill-slot="foo">
> blah
> </div>
> </html>
>
> Would the above work?
Why dontcha try it out?!?
Anyway, it looks like lots of unnecessary typing. Just register the
tempalte with the macro as a page and access the macro as outlined above.
--
http://worldcookery.com -- Professional Zope documentation and training
Next Zope 3 training at Camp5: http://trizpug.org/boot-camp/camp5
More information about the z3-five
mailing list