public void RenderTemplate(string templateName, object model) { string templateFullPath = applicationInfo.AbsolutizePath("Web/Pages/Templates/" + templateName + ".vm.html"); ITemplateSource template = new CacheableFileTemplate( templateFullPath, fileCache); string templateText = template.GetTemplate(); VelocityEngine velocity = new VelocityEngine(); velocity.Init(); VelocityContext velocityContext = new VelocityContext(); velocityContext.Put("m", model); velocityContext.Put("h", this); using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { if (false == velocity.Evaluate(velocityContext, stringWriter, null, templateText)) throw new InvalidOperationException("Template expansion failed"); writer.InnerWriter.Write(stringWriter.ToString()); } writer.WriteLine(); }
public void RenderTemplate(string templateName, object model) { string templateFullPath = applicationInfo.AbsolutizePath("Web/Pages/Templates/" + templateName + ".vm.html"); ITemplateSource template = new CacheableFileTemplate( templateFullPath, fileCache); string templateText = template.GetTemplate(); VelocityEngine velocity = new VelocityEngine(); velocity.Init(); VelocityContext velocityContext = new VelocityContext(); velocityContext.Put("m", model); velocityContext.Put("h", this); using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { if (false == velocity.Evaluate(velocityContext, stringWriter, null, templateText)) { throw new InvalidOperationException("Template expansion failed"); } writer.InnerWriter.Write(stringWriter.ToString()); } writer.WriteLine(); }