[ http://issues.apache.org/jira/browse/VELOCITY-504?page=comments#action_12461554 ] Will Glass-Husain commented on VELOCITY-504: --------------------------------------------
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. > Call to evaluate inside of macro fails with 1.5 beta2 > ----------------------------------------------------- > > Key: VELOCITY-504 > URL: http://issues.apache.org/jira/browse/VELOCITY-504 > Project: Velocity > Issue Type: Bug > Components: Engine > Affects Versions: 1.5 beta2 > Environment: Windows XP, Sun J2SE 1.5.0_09 > Reporter: Reggie Riser > Assigned To: Henning Schmiedehausen > Fix For: 1.5 > > Attachments: macrotest.zip > > > When upgrading from 1.5 beta 1 to beta2, I ran into a problem with one of our > macros that makes a call to Velocity.evaluate (via a tool) within a foreach > loop. With beta 1, everything worked fine. But we get a "cannot be > resolved" error with beta 2. The same code works fine outside of a macro > with either version. > I've distilled the issue we're having down to a simple test case and have > attached example code and a build file showing the problem. Just do an "ant > beta1" or "ant beta2" to see how the results differ between beta1 and beta2. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
