velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Boris Partensky <>
Subject upgrading from 1.5 to 1.7 compatibility issues
Date Mon, 30 Apr 2012 15:49:39 GMT
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();


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

        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)"+
                          "#macro(innerMacro $arg2)$arg1#end"+

        String eval = evaluate(template);
        assertEquals(eval, "outermacroparam", eval);


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message