Macros with same name in different templates creates issue when VelocityEngine 
initialized with init(Properties) method
-----------------------------------------------------------------------------------------------------------------------

                 Key: VELOCITY-747
                 URL: https://issues.apache.org/jira/browse/VELOCITY-747
             Project: Velocity
          Issue Type: Bug
          Components: Engine
    Affects Versions: 1.6.x
            Reporter: Ravikanth L


I have two different templates with same macro names performing different 
functions. Works fine when VelocityEngine is initialized with 
init(propsFileName).

When VelocityEngine is initialized with init(Properties), macro defined in 
template1 will be used when macro defined in template2 is called.

Ex:

one.vm:
#macro ( myMacro )
This is from myMacro macro of one.vm
#end
#myMacro

two.vm
#macro ( myMacro )
This is from myMacro macro of two.vm
#end
#myMacro

settings in my velocity.properties:
directive.foreach.counter.initial.value = 1
file.resource.loader.path = E:/Programs
file.resource.loader.cache = true
file.resource.loader.modificationCheckInterval = -1

velocimacro.permissions.allow.inline.local.scope = true  
directive.set.null.allowed = true
velocimacro.max.depth = -1

code in java file:

                VelocityEngine engine = new VelocityEngine();
                Properties props = new Properties();
                props.load( new FileInputStream("velocity.properties") );
                engine.init(props);
                //engine.init("velocity.properties");
                StringWriter writer = new StringWriter();
                VelocityContext ctx = new VelocityContext();
                engine.mergeTemplate("one.vm","UTF-8", ctx,writer);
                System.out.println("Template 1 output:" + writer.toString());
                StringWriter writerTwo = new StringWriter();
                engine.mergeTemplate("two.vm","UTF-8", ctx,writerTwo);
                System.out.println("Template 2 output:" + writerTwo.toString());

Expected output :
Template 1 output:This is from Test1 macro of one.vm

Template 2 output:This is from Test1 macro of two.vm

Actual output:
Template 1 output:This is from Test1 macro of one.vm

Template 2 output:This is from Test1 macro of one.vm

But with the same code will work properly when initialized with the commented 
line i.e. engine.init("velocity.properties");

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to