You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Ravikanth L (JIRA)" <de...@velocity.apache.org> on 2009/12/02 14:20:23 UTC

[jira] Created: (VELOCITY-747) Macros with same name in different templates creates issue when VelocityEngine initialized with init(Properties) method

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: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Updated: (VELOCITY-747) Macros with same name in different templates creates issue when VelocityEngine initialized with init(Properties) method

Posted by "Ravikanth L (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELOCITY-747?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ravikanth L updated VELOCITY-747:
---------------------------------

    Description: 
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");

  was:
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");


> 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: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Updated: (VELOCITY-747) Macros with same name in different templates creates issue when VelocityEngine initialized with init(Properties) method

Posted by "Ravikanth L (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELOCITY-747?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ravikanth L updated VELOCITY-747:
---------------------------------

    Attachment: VelocityInitializationExample.ZIP

> 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
>         Attachments: VelocityInitializationExample.ZIP
>
>
> 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: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org