NVelocity: loading templates from embedded resources
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);