/// <summary> /// Stock implementation of RenderTemplate that doesn't allow for /// any sort of assembly caching. Instead it creates and re-renders /// templates read from the reader each time. /// /// Custom implementations of RenderTemplate should be created that /// allow for caching by examing a filename or string hash to determine /// whether a template needs to be re-generated and compiled before /// rendering. /// </summary> /// <param name="reader">TextReader that points at the template to compile</param> /// <param name="model">Optional context to pass to template</param> /// <param name="writer">TextReader passed in that receives output</param> /// <returns></returns> public bool RenderTemplate(TextReader reader, object model, TextWriter writer) { string assemblyId = Engine.CompileTemplate(reader); if (assemblyId == null) { ErrorMessage = Engine.ErrorMessage; return(false); } return(RenderTemplateFromAssembly(assemblyId, model, writer)); }
/// <summary> /// Stock implementation of RenderTemplate that doesn't allow for /// any sort of assembly caching. Instead it creates and re-renders /// templates read from the reader each time. /// /// Custom implementations of RenderTemplate should be created that /// allow for caching by examing a filename or string hash to determine /// whether a template needs to be re-generated and compiled before /// rendering. /// </summary> /// <param name="reader">TextReader that points at the template to compile</param> /// <param name="model">Optional model data to pass to template</param> /// <param name="writer">TextReader passed in that receives output</param> /// <returns></returns> public virtual bool RenderTemplate(TextReader reader, object model, TextWriter writer) { LastException = null; string assemblyId = Engine.CompileTemplate(reader); if (assemblyId == null) { SetErrorException(new RazorHostContainerException(Engine.ErrorMessage, Engine.LastGeneratedCode, Engine.LastException, null, null)); return(false); } return(RenderTemplateFromAssembly(assemblyId, model, writer)); }