Ok, figured this out. I made an even simpler example; I can post it if others want to look at it.
This example is in direct conflict to the bug fix in
VELOCITY-285. In that issue we made it so that loop references are local to a macro. This was done because of problems with recursive macros-- with a macro and a loop the loop references needed to be kept distinct.
The problem here is that the evaluated text passed to $tool.eval() (called within the macro) refers to $name, which is the loop reference. Since $tool.eval is accessing the global context, and $name is within the macro local context it cannot be referenced by $tool.eval().
A workaround for this situation is to use #set($name2 = $name) and then have the evaluated text refer to $name2. This works fine, since $name2 is set within the global context by default (unless velocimacro.context.localscope = true).
Bottom line, the bug fix for
VELOCITY-285 is not backwards compatible. But, this is such a rare case (calling an evaluation tool and referencing the loop variable) AND there's a workaround I'm inclined to leave this as is. (with a note in the README file?)
Comments? Particularly from Henning.