Hello,
I have the following problem : I would like to call a macro but the macro name must be a variable. Ex: instead of #renderLabel($component) to have #call("renderLabel" $component) - of course "renderLabel" can be any (existing) macro name. I started to create a directive #call, but of course the render method fails because the nodeTree is not initialized. nodeTree is initialized during parsing like this public class ASTDirective extends SimpleNode { ... directive = rsvc.getVelocimacro( directiveName, context.getCurrentTemplateName()); try { directive.init( rsvc, context, this ); } .. { Any thoughts? I think such a directive is very useful, I don't know why is not part of the library. Thanks. CallDirective source code : public class CallDirective extends Directive { public String getName() { return "call"; } public int getType() { return LINE; } public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { if (node.jjtGetNumChildren() < 1) { rsvc.error("#" + getName() + " : invalid number of parameters, must be at least the macro name and 0..N parameters"); return false; } String macroName = (String) node.jjtGetChild(0).value(context); VelocimacroProxy velocimacro = (VelocimacroProxy) rsvc.getVelocimacro(macroName, context.getCurrentTemplateName()); if (velocimacro == null) { rsvc.error("A macro with name '" + macroName + " in context '" + context.getCurrentTemplateName() + "' doesn't exists"); return false; } return velocimacro.render(context, writer, node); } }