I've always used #if to implement the 'switch' but I think, even for 3-4
conditions, the template will look cleaner.
Instead of
#if('renderLabel' == $macroToCall)
#renderLabel($component)
#elseif('renderInput' == $macroToCall)
#renderInput($component)
#elseif(...)
...
#end
we will have
#call($macroToCall $component).
In case of a value outside the 'domain' you will get an exception "Macro
not found ....".
We could have even a directive which will simulate the switch default
branch.
#callWithDefault($macroToCall $defaultMacro ....) - of course the name
should be shorter.
Christopher Schultz wrote:
Adrian,
Adrian Tarau wrote:
I have the following problem : I would like to call a macro but the
macro
name must be a variable.
This is more of a question for the user's list, not the dev list. In
the future, please post there.
Ex: instead of #renderLabel($component) to have #call("renderLabel"
$component) - of course "renderLabel" can be any (existing) macro name.
How many possibilities can you have for $component? Are they
unlimited, or constrained to maybe 5 possibilities? I'm wondering
because you could easily do it like a switch:
#if('renderLabel' == $macroToCall)
#renderLabel($component)
#elseif('renderInput' == $macroToCall)
#renderInput($component)
#elseif(...)
...
#end
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]