execute method
Executes the statement within the given ctx and returns the result as a JinjaValue.
Implementation
@override
JinjaValue execute(Context ctx) {
if (name is! Identifier) {
throw Exception('Macro name must be identifier');
}
final macroName = (name as Identifier).name;
final func = JinjaFunction(macroName, (callArgs, callKwargs) {
// Create macro context
final macroCtx = ctx.derive();
_bindParameters(macroName, args, callArgs, callKwargs, macroCtx, ctx);
// Inject 'caller' if present in kwargs (from {% call %})
if (callKwargs.containsKey('caller')) {
macroCtx.set('caller', callKwargs['caller']!);
}
return _execCaptured(body, macroCtx);
});
ctx.set(macroName, func);
return const JinjaNone();
}