ZPT macro using a macro from the same page template
Hi, I made an all purpose widget macros collection template, and one macro from the template is used by another one. Is there a kind of shortcut to tell the main macro that the secondary macro is defined in the same template ? <div metal:define-macro="aux"> </div> <div metal:define-macro="main"> <div metal:use-macro="xxx/aux"> </div> </div> Thanks in advance for the hints --Gilles
template/macros/aux jens On Tuesday, Jul 22, 2003, at 09:44 US/Eastern, Gilles Lenfant wrote:
Hi,
I made an all purpose widget macros collection template, and one macro from the template is used by another one.
Is there a kind of shortcut to tell the main macro that the secondary macro is defined in the same template ?
<div metal:define-macro="aux"> </div> <div metal:define-macro="main"> <div metal:use-macro="xxx/aux"> </div> </div>
Thanks in advance for the hints
--Gilles
----- Original Message ----- From: "Jens Vagelpohl" <jens@zope.com> To: "Gilles Lenfant" <gilles@pilotsystems.net> Cc: <zope@zope.org> Sent: Tuesday, July 22, 2003 4:57 PM Subject: Re: [Zope] ZPT macro using a macro from the same page template
template/macros/aux
jens
Thanks but, it seems that no ! In that case, "template" refers to the Page templates that uses the "main" macro (any template in the site). It seems that "template", "here" (...) are passed along from the first Page template executed to the ones that contain the executed macros. --Gilles
On Tuesday, Jul 22, 2003, at 09:44 US/Eastern, Gilles Lenfant wrote:
Hi,
I made an all purpose widget macros collection template, and one macro from the template is used by another one.
Is there a kind of shortcut to tell the main macro that the secondary macro is defined in the same template ?
<div metal:define-macro="aux"> </div> <div metal:define-macro="main"> <div metal:use-macro="xxx/aux"> </div> </div>
Thanks in advance for the hints
--Gilles
On Tue, Jul 22, 2003 at 05:34:41PM +0200, Gilles Lenfant wrote:
Thanks but, it seems that no ! In that case, "template" refers to the Page templates that uses the "main" macro (any template in the site). It seems that "template", "here" (...) are passed along from the first Page template executed to the ones that contain the executed macros.
ohhh crud. You're right; the macros are not evaluated until they are used by the template that does use-macro. in that case, you'll need to have a way to get to the original template by name. The simplest is to give the name explicitly, e.g. here/some_template_name/macros/aux -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's THE FOUL CONTROLLER! (random hero from isometric.spaceninja.com)
On Tue, Jul 22, 2003 at 11:26:57AM -0400, Paul Winkler wrote:
in that case, you'll need to have a way to get to the original template by name. The simplest is to give the name explicitly, e.g. here/some_template_name/macros/aux
another technique if you need something more flexible: http://www.zopelabs.com/cookbook/1014285275 -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's THE SPOOKY BLADE! (random hero from isometric.spaceninja.com)
----- Original Message ----- From: "Paul Winkler" <pw_lists@slinkp.com> To: <zope@zope.org> Sent: Tuesday, July 22, 2003 5:36 PM Subject: Re: [Zope] ZPT macro using a macro from the same page template
On Tue, Jul 22, 2003 at 11:26:57AM -0400, Paul Winkler wrote:
in that case, you'll need to have a way to get to the original template by name. The simplest is to give the name explicitly, e.g. here/some_template_name/macros/aux
another technique if you need something more flexible: http://www.zopelabs.com/cookbook/1014285275
Thanks Paul, I was in just process to experiment the Python way. This confirms I was in the good way. --Gilles
On Tue, Jul 22, 2003 at 03:44:17PM +0200, Gilles Lenfant wrote:
Hi,
I made an all purpose widget macros collection template, and one macro from the template is used by another one.
Is there a kind of shortcut to tell the main macro that the secondary macro is defined in the same template ?
<div metal:define-macro="aux"> </div> <div metal:define-macro="main"> <div metal:use-macro="xxx/aux"> </div> </div>
untested, but this seems like the obvious solution to me: <div metal:define-macro="main"> <div metal:use-macro="template/macros/aux"> </div> </div> -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's ULTRA PRETERNATURAL SHEPHERD! (random hero from isometric.spaceninja.com)
Gilles Lenfant wrote at 2003-7-22 15:44 +0200:
I made an all purpose widget macros collection template, and one macro from the template is used by another one.
Is there a kind of shortcut to tell the main macro that the secondary macro is defined in the same template ?
<div metal:define-macro="aux"> </div> <div metal:define-macro="main"> <div metal:use-macro="xxx/aux"> </div> </div>
Unfortunately not. I consider this a major drawback as it prevents the definition of macro libraries. Nowadays, we almost always use ZPT through CMF's "portal_skins". Therefore, "container" is the portal and we access the ZPTs via "container/ZPT_id". Dieter
----- Original Message ----- From: "Dieter Maurer" <dieter@handshake.de> To: "Gilles Lenfant" <gilles@pilotsystems.net> Cc: <zope@zope.org> Sent: Tuesday, July 22, 2003 11:31 PM Subject: Re: [Zope] ZPT macro using a macro from the same page template
Gilles Lenfant wrote at 2003-7-22 15:44 +0200:
I made an all purpose widget macros collection template, and one macro from the template is used by another one.
Is there a kind of shortcut to tell the main macro that the secondary macro is defined in the same template ?
<div metal:define-macro="aux"> </div> <div metal:define-macro="main"> <div metal:use-macro="xxx/aux"> </div> </div>
Unfortunately not.
I consider this a major drawback as it prevents the definition of macro libraries.
Hi Dieter, Agree. IMO, some "thistemplate" like global variable in TALES expressions would fix this in an elegant way. But dunno if this is an easy work. Gonna find the "wish list" for ZPT :o)
Nowadays, we almost always use ZPT through CMF's "portal_skins". Therefore, "container" is the portal and we access the ZPTs via "container/ZPT_id".
Making something like this in CMF/Plone but this goes through the acquisition machinery to find the page template itself. The above stated solution would do this faster. And I sometimes make stuff with no CMF/Plone :o) Cheers --Gilles
Gilles Lenfant wrote at 2003-7-23 12:15 +0200:
.... IMO, some "thistemplate" like global variable in TALES expressions would fix this in an elegant way. But dunno if this is an easy work.
I looked into it to extend Page Template accordingly. However, it turned out to be too difficult: Passed in slots would need to be treated as closures (code + variable bindungs) as such a slot logically belongs to the macro-user and not the macro. Context would have to change at every boundary of a macro use or a filled in slot.
Nowadays, we almost always use ZPT through CMF's "portal_skins". Therefore, "container" is the portal and we access the ZPTs via "container/ZPT_id".
Making something like this in CMF/Plone but this goes through the acquisition machinery to find the page template itself. The above stated solution would do this faster.
Right.
And I sometimes make stuff with no CMF/Plone :o) Cheers
My "SkinnedFolder" product may help: <http://www.dieter.handshake.de/pyprojects/zope> Dieter
participants (4)
-
Dieter Maurer -
Gilles Lenfant -
Jens Vagelpohl -
Paul Winkler