[Zope] Re: metal:use-macro

Gilles Lenfant glenfant at bigfoot.com
Tue Dec 30 16:06:04 EST 2003


> "David Sumner" <david at dragontail.com> a écrit dans le message de
news:000201c3cef2$4ac27010$0300000a at nomad...
> Hello,
> Thanks,
> David

[ didn't copy the source cause you posted in HTML :-( ]

metal:use-macro requires a TALES expression.

You could use such a thing in your publishing template...

<html metal:use-macro="python: here.macroChooser(someCriteria)">
...
</html>

Let's assume that all your macros "macro1" and "macro2" are in a template
called "all_macros", the script "macroChooser" could look like this...

##parameters=someCriteria
if myCondition(someCriteria):
  macroname = 'macro1'
else:
  macroname = 'macro2'

return context.all_macros.macros[macroname]

Untested but this should work...
Of course, you could have your own logic to return the appropriate macro in
"macroChooser" (playing with several macro collections templates...)

HTH

--
Gilles









More information about the Zope mailing list