On Fri, 2002-08-23 at 06:25, Dieter Maurer wrote:
KevinL writes:
On Thu, 2002-08-22 at 04:30, Dieter Maurer wrote:
zope writes:
... Now all my macros are in the same page. I m am trying to use : <div tal:condition="request/form/lkid | nothing"> <tal:block define="mName python:here.oms.Users.lib.pset_links(lkid=request.form['lkid'])"> <metal:block use-macro="container/zptmac_memall/macros/?mName"> List </metal:block> This does not work, because TAL-attributes are only evaluated once all METAL-attributes have been executed.
As a consequence you must not refer to a TAL defined variable in a METAL attribute.
Use a Python script to return the macro object you need.
Furthermore, you cannot suppress a METAL attribute execution with a "tal:condition" (for the same reasons).
Use an (almost) empty macro in such a case (it may need to define slots, when you call it with "metal:fill-slot").
Um. That's wrong, I believe. It's explicitely stated in the documentation.
And, think a moment:
Many tal attributes reference things available only under special circumstances, e.g. form variables. When you evaluate them in a different context, you will get exceptions.
Then, think of macro expansion. When macro expansion is enabled, you expand macros outside when you look at the template source, outside of any special context. You cannot rely on tal attributes for that.
Of course, it would be possible to not look at tal attributes when macro expansion is enable but look at them when it is disabled. But that would be a really strange design....
Dieter
I just added a page template, test_macro, and surrounded the default content with "metal:block define-macro="test". I added another ptl, test, and made it consist entirely of: <span tal:define="mName string:test"> <metal:block use-macro="here/test_macro/macros/?mName"> </metal:block> </span> When you view test, you get the test_macro macro appearing. This works. More than that, the conditional picking of macros like that is important, I think - otherwise a lot of the dynamicness of a site vanishes. Perhaps we're talking at cross-purposes? Or have I been relying on a brokenness in macros/tal? I can certainly see in the documentation that it says macros are expanded before tal is executed, but that seems to not be the case in practice? KevinL