Maybe something is escaping my view, but I believe this
is unecessary overhead. What does "patch in the arguments at
runtime into the reference nodes" mean?
> > While looking at the Macro implementation, the proxy I guess,
> > I noticed that macros are getting reparsed every time they are
> > expanded. Can some one explain why the reparsing is necessary?
>
> That's version 0.0, and was done just to get it out there.
>
> It's necessary because you can invoke a VM multiple times in a template
> with different args, so the args must be changed from iteration to
> iteration. Currently, the cheapest hack was to do that and simply use
> the parser to generate a new correct AST and then merge that, producing
> the output stream that is inserted at the right place.
>
> My intent for the optimized version will be to parse the tree once and
> store it, and patch in the arguments at runtime into the reference
> nodes. That will be as fast as 'regular templates' then.
Why can't the macro implementation just take the parsed AST tree;
when called: save the current context args used by it, render the tree,
and finally restore the args for the context (procedure similar to the
foreach directive)?
:) Christoph