fill-slot condition possible?
Hello, is it possible when using a macro to conditionally fill a slot ? In the same template, that is... Sometimes i want the slot filled, other times i would like to keep the default content of the slot. This is easy with two distinct templates, but in the same template ? -- Sune B. Wøller
Sune Brøndum Wøller wrote:
is it possible when using a macro to conditionally fill a slot ? In the same template, that is...
It's sort of possible, but messy: <div metal:define-macro="mymacro"> Blah, blah... <div metal:define-slot="myslot"><metal:slot define-macro="myslot"> Default contents of slot </metal:slot></div> </div> <div metal:use-macro="template/macros/mymacro"> <div metal:fill-slot="myslot" tal:define="filled some_condition"> <p tal:condition="filled"> New Contents </p> <metal:slot tal:condition="not:filled" use-macro="template/macros/myslot" /> </div> </div> Cheers, Evan @ 4-am
yes, it is a bit messy - but it works! maybe the possiblity to calculate slot-names with TALES, like you can with macros, or to create a kind of fill-slot-if statement should be considered in future revisions of METAL ? thanks for your help, Sune B. Wøller
Sune Brøndum Wøller wrote:
is it possible when using a macro to conditionally fill a slot ? In the same template, that is...
It's sort of possible, but messy:
<div metal:define-macro="mymacro"> Blah, blah... <div metal:define-slot="myslot"><metal:slot define-macro="myslot"> Default contents of slot </metal:slot></div> </div>
<div metal:use-macro="template/macros/mymacro"> <div metal:fill-slot="myslot" tal:define="filled some_condition"> <p tal:condition="filled"> New Contents </p> <metal:slot tal:condition="not:filled" use-macro="template/macros/myslot" /> </div> </div>
Cheers,
Evan @ 4-am
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Try this: <tal:block condition="your/condition/here"> <metal:block fill-slot="xxx"> blah,blah,blah </metal:block> </tal:block> it should work...
-----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org]On Behalf Of Sune Brøndum Wøller Sent: Monday, January 26, 2004 3:35 PM To: zope Subject: [Zope] fill-slot condition possible?
Hello, is it possible when using a macro to conditionally fill a slot ? In the same template, that is...
Sometimes i want the slot filled, other times i would like to keep the default content of the slot. This is easy with two distinct templates, but in the same template ?
-- Sune B. Wøller
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org]On Behalf Of Mauricio Souza Lima Sent: 26. januar 2004 20:40 To: zope Subject: RE: [Zope] fill-slot condition possible?
Try this:
<tal:block condition="your/condition/here"> <metal:block fill-slot="xxx"> blah,blah,blah </metal:block> </tal:block>
it should work...
The tal statements are never evaluated, since the fill-slot offcourse is inside a use-macro statement. Tal is evaluated after metal. So far I have to use the macro twice, or create two templates. But i would rather not. I was thinking : <span tal:fill-slot="python:'slotname' and condition or 'dummy'"> but that doesnt work. /sune wøller
-----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org]On Behalf Of Sune Brøndum Wøller Sent: Monday, January 26, 2004 3:35 PM To: zope Subject: [Zope] fill-slot condition possible?
Hello, is it possible when using a macro to conditionally fill a slot ? In the same template, that is...
Sometimes i want the slot filled, other times i would like to keep the default content of the slot. This is easy with two distinct templates, but in the same template ?
-- Sune B. Wøller
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Evan Simpson -
Mauricio Souza Lima -
Sune Br�ndum W�ller