NVelocity templates and absolute paths
We’ve started using the NVelocity template formatting engine. We were absolutely stymied for an hour, trying to figure out how to get it working with an absolute path to the template file, instead of the relative path shown in the documentation.
The trick is to set file.resource.loader.path. Here’s how to load C:\foo\bar\somefile.vm:
ExtendedProperties props = new ExtendedProperties(); props.AddProperty("file.resource.loader.path", new ArrayList(new string[]{".", "C:\\"})); velocity.Init(props); template = velocity.GetTemplate("foo\\bar\\somefile.vm");
blog comments powered by Disqus