You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Will Glass-Husain (JIRA)" <de...@velocity.apache.org> on 2007/04/20 16:35:15 UTC

[jira] Closed: (VELOCITY-539) Velocity cannot handle relative paths in included (#parse) files.

     [ https://issues.apache.org/jira/browse/VELOCITY-539?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Will Glass-Husain closed VELOCITY-539.
--------------------------------------

    Resolution: Won't Fix

This is by design.  #include/#parse searches for the template in the base path.

You can install the IncludeRelativePath event handler to change the behavior to search relative to the parent template.

Need more help?  Subscribe to user@velocity.apache.org - this is not really a good place to discuss such issues.

WILL

> Velocity cannot handle relative paths in included (#parse) files.
> -----------------------------------------------------------------
>
>                 Key: VELOCITY-539
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-539
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: Linux rj 2.6.16-rc6 #1 SMP PREEMPT Thu Mar 16 13:52:44 CET 2006 i686 Intel(R) Pentium(R) 4 CPU 3.20GHz GenuineIntel GNU/Linux
> Java(TM) SE Runtime Environment (build 1.6.0-b105)
> Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode)
> -
>            Reporter: Robbert-Jan Roos
>            Priority: Minor
>
> situation:
> /tmp/template.vtl: #parse("dir/tmpl2.vtl")
> /tmp/dir/tmpl2.vtl: #parse("tmpl3.vtl")
> /tmp/dir/tmp;3.vtl: "Hello world!"
> code:
> public class Test {
> public static void main(String[] args) throws Exception {
> 		Properties p = new Properties();
> 		p.setProperty("file.resource.loader.path", "/tmp");
> 		Velocity.init(p);
> 		StringWriter out = new StringWriter();
> 		Velocity.mergeTemplate("template.vtl", "UTF-8", new VelocityContext(), out);
> 		System.out.println(out.getBuffer().toString());
> 	}
> }
> result:
> Exception in thread "main" org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'template3.vtl'
> 	at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:452)
> 	at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:335)
> 	at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1102)
> 	at org.apache.velocity.runtime.directive.Parse.render(Parse.java:177)
> 	at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:170)
> 	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
> 	at org.apache.velocity.runtime.directive.Parse.render(Parse.java:224)
> 	at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:170)
> 	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
> 	at org.apache.velocity.Template.merge(Template.java:254)
> 	at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:483)
> 	at nl.basenet.apps.rj.Test.main(Test.java:16)

-- 
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