[Zope3-dev] Re: tal:define="..." considered harmful?

Jean-Marc Orliaguet jmo at ita.chalmers.se
Mon Feb 13 11:42:24 EST 2006


Tres Seaver wrote:

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Tonico Strasser wrote:
>
>  
>
>>I'm interested in your opinion about parameters for macros.
>>
>>Do you think this is explicit enough?:
>>
>><ul tal:define="list main_navigation">
>>  <li metal:use-macro="macros/li_repeat"/>
>></ul>
>>
>>Or do you think explicit parameters would make things clearer?:
>>
>><ul>
>>  <li metal:use-macro="macros/li_repeat"
>>      metal:with-params="list main_navigation"/>
>></ul>
>>    
>>
>
>I don't favor "explict arguments" for macros, becaued I don't think they
>are functions.  I normally document the "expected names" in a comment in
>the supplying template (outside the macro itself).
>
>
>Tres.
>  
>

except that this is not about physically passing data to the macro as if 
it was a function (or updating some stack), this is about telling the 
macro from where to pull the data.

for instance if you have a data structure:

data = {
  'items1': [...]
  'items2': [...]
}

you'd write:

<li metal:use-macro="macros/li_repeat"  metal:with-params="items1 "/>

provided that the 'li_repeat' macro needs a data structure of the same 
type as 'items1'.

in the current implementation one template provides data for another 
template acting as some sort of proxy for the model (which translates 
into complicated dependency chains since there is no reason to proxy 
data only once).

regards
/JM


More information about the Zope3-dev mailing list