velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Glass-Husain <wgl...@forio.com>
Subject Re: ClasspathResourceLoader with/without leading slash
Date Mon, 17 Jul 2006 20:40:46 GMT
Hi Bradley,

I think this works in the (as yet) unreleased Velocity 1.5.  It's pretty 
stable, you can download it, compile it and use it.

If you want to make it relative, you might try writing your own resource 
loader.  It's a fairly simple API.  Just grab the code for 
ClasspathResourceLoader from the source and modify it.  Then specify 
this custom resource loader in your velocity.properties.

There's some more info on writing custom resource loaders on the Wiki 
here and elsewhere:
http://wiki.apache.org/jakarta-velocity/HackingVelocity

Best, WILL

Bradley Wagner wrote:
> I'm using Velocity-1.4 and I'm experiencing problems with loading 
> templates using the ClasspathResourceLoader. Basically, the only way I 
> can get it to work is by dropping the leading slash on my absolute 
> classpath.
>
> Template template = Velocity.getTemplate("class/path/to/file")
>
> Also, is there any way to reference something relative to your current 
> class as you can do with the resource loader in Java?
>
> MyClass.class.getResourceAsStream("./relative/to/current")
>
> Thanks,
> Bradley
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>

-- 
Forio Business Simulations

Will Glass-Husain
phone (415) 440-7500 x89
mobile (415) 235-4293
wglass@forio.com
www.forio.com


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


Mime
View raw message