[Zope] Re: Filling a metal slot which name is known only at run time

Evan Simpson evan at tokenexchange.com
Tue Dec 14 13:46:49 EST 2004


Martin Aspeli wrote:
> When viewing the CompositePage, it will do the following:
> 
> <metal:layout use-macro="here/getChosenLayoutTemplate">
>     <metal:composite fill-slot="top_slot">
>         <div tal:content="structure python:here.renderContentForSlot  
> ('top_slot')"/>
>     </metal:composite>
>     <metal:composite fill-slot="bottom_slot">
>         <div tal:content="structure python:here.renderContentForSlot  
> ('bottom_slot')"/>
>     </metal:composite>
> </metal:layout>

Ah, so you want layout template authors to be able to define slots with 
semi-meaningful names, then programmatically fill those slots with 
either a content-selector widget or the selected content.  The fact that 
'fill-slot' only accepts a literal string isn't a surface detail -- 
you'd have to go deep into the guts of the TAL interpreter to change 
that. The best way I can think of to deal with this is to actually 
generate the ZPT text with the slot names filled in, as in the example 
above, and compile the text as a template.

Cheers,

Evan @ 4-am



More information about the Zope mailing list