Hello, while going through the upgrade I noticed an incompatible
behavior during nested macro evaluation. Looks like in 1.7 (all
default properties) child macro has access to variables set in parent
macro scope (and those take precedence over globals), and 1.5 sees
globals. In the following example, in 1.5 unit test the following
template will evaluate to "globalvar", and in 1.7 - to
"outermacroparam". Is this expected behavior?


1.5 test case


public void testVelocityNestedMacroScope() throws Exception
    {
        VelocityEngine ve = new VelocityEngine();

        ve.init();

        String template = "#macro(outerMacro $arg1)"+
                          "#innerMacro('blah')"+
                          "#end"+
                          "#macro(innerMacro $arg2)$arg1#end"+

"#set($arg1='globalval')#outerMacro('outermacroparam')";
        StringWriter eval = new StringWriter();
        boolean b = ve.evaluate(new VelocityContext(), eval, "foo", template);
        assertEquals(eval.toString(), "globalval", eval.toString());

    }

1.7 test case


 public void testVelocityNestedMacroScope()
    {
        String template = "#macro(outerMacro $arg1)"+
                          "#innerMacro('blah')"+
                          "#end"+
                          "#macro(innerMacro $arg2)$arg1#end"+

"#set($arg1='globalvar')#outerMacro('outermacroparam')";
        String eval = evaluate(template);
        assertEquals(eval, "outermacroparam", eval);

    }

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
For additional commands, e-mail: user-h...@velocity.apache.org

Reply via email to