Reputation: 77
is it somehow possible to call a velocity macro by name e.g.:
#macro (sayHello)
Hello!
#end
#set ($macroName = "sayHello")
#$macroName()
Thanks!
Upvotes: 3
Views: 661
Reputation: 2564
A quick scan of the docs does not indicate support for this. But you could do something like the following:
#macro(myMacro1 $param1 $param2)
## stuff here...
#end
#macro(myMacro2 $param1 $param2)
## stuff here...
#end
#if($condition)
#myMacro1
#else
#myMacro2
#end
Or maybe your macro needs to take in additional parameters to account for all scenarios.
Upvotes: 0