public void SimpleTemplateProcessingWithinTwoResources() { NVelocityTemplateEngine engine = new NVelocityTemplateEngine(); engine.AddResourceAssembly("Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine.Tests"); engine.AddResourceAssembly("Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine.Tests.SR"); (engine as ISupportInitialize).BeginInit(); StringWriter writer = new StringWriter(); string templateFile = "Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine.Tests/compiledres/simple.vm"; Assert.IsTrue(engine.Process( new Hashtable(), templateFile, writer)); Assert.AreEqual("This is a simple template", writer.GetStringBuilder().ToString()); // clear the writer for the second run writer = new StringWriter(); string secondTemplateFile = "Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine.Tests.SR/compiledres/simple.vm"; Assert.IsTrue(engine.Process( new Hashtable(), secondTemplateFile, writer)); Assert.AreEqual("This is the second simple template", writer.GetStringBuilder().ToString()); }
public void SimpleTemplateProcessingWithinTwoResources() { NVelocityTemplateEngine engine = new NVelocityTemplateEngine(); engine.AddResourceAssembly("TemplateEngine.NVelocityTemplateEngine.Tests"); engine.AddResourceAssembly("Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine.SR"); (engine as ISupportInitialize).BeginInit(); StringWriter writer = new StringWriter(); string templateFile = "Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine.Tests/compiledres/simple.vm"; Assert.IsTrue(engine.Process( new Hashtable(), templateFile, writer)); Assert.AreEqual("This is a simple template", writer.GetStringBuilder().ToString()); // clear the writer for the second run writer = new StringWriter(); string secondTemplateFile = "Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine.SR/compiledres/simple.vm"; Assert.IsTrue(engine.Process( new Hashtable(), secondTemplateFile, writer)); Assert.AreEqual("This is the second simple template", writer.GetStringBuilder().ToString()); }
private static void InitializeTemplateEngine() { if (templateEngine == null) { var nvelTemplateEng = new NVelocityTemplateEngine(); #if USE_LOCAL_TEMPLATES nvelTemplateEng.TemplateDir = @"E:\dev\castle\trunk\MonoRail\Castle.MonoRail.ActiveRecordSupport.Scaffold\Templates\"; nvelTemplateEng.BeginInit(); nvelTemplateEng.EndInit(); #else nvelTemplateEng.AddResourceAssembly("Castle.MonoRail.ActiveRecordSupport"); nvelTemplateEng.BeginInit(); nvelTemplateEng.EndInit(); #endif templateEngine = nvelTemplateEng; } }