George V. Reilly

NVelocity: loading templates from embedded resources

NVelocity

In last week’s tip on using the NVelocity template formatting engine, I described what to set to load a template from an absolute path.

Here’s the magic necessary to get NVelocity to load a template from an embedded resource:

VelocityEngine engine = new VelocityEngine();
ExtendedProperties properties = new ExtendedProperties();
properties.AddProperty("resource.loader", "assembly");
properties.AddProperty("assembly.resource.loader.class",
    "NVelocity.Runtime.Resource.Loader.AssemblyResourceLoader, NVelocity");
properties.AddProperty("assembly.resource.loader.assembly", "StencilFormatter");
engine.Init(properties);
blog comments powered by Disqus
NVelocity templates and absolute paths » « Damn Right We're Angry