Tres Seaver wrote:

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"/>

Or do you think explicit parameters would make things clearer?:

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

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).


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).

Zope3-dev mailing list

Reply via email to