public Response RenderView(ViewLocationResult viewLocationResult, dynamic model, IRenderContext renderContext) { var template = renderContext.ViewCache.GetOrAdd(viewLocationResult, result => { try { var context = new NancyVeilContext(renderContext, Extensions); var engine = new VeilEngine(context); Type modelType = model == null ? typeof(object) : model.GetType(); return engine.CompileNonGeneric(viewLocationResult.Extension, result.Contents(), modelType); } catch (Exception e) { return CreateErrorPage(e); } }); var response = new HtmlResponse(); response.ContentType = "text/html; charset=utf-8"; response.Contents = s => { var writer = new StreamWriter(s, Encoding.UTF8); template(writer, model); writer.Flush(); }; return response; }
public Response RenderView(ViewLocationResult viewLocationResult, dynamic model, IRenderContext renderContext) { var template = renderContext.ViewCache.GetOrAdd(viewLocationResult, result => { try { var context = new NancyVeilContext(renderContext, Extensions); var engine = new VeilEngine(context); Type modelType = model == null ? typeof(object) : model.GetType(); return(engine.CompileNonGeneric(viewLocationResult.Extension, result.Contents(), modelType)); } catch (Exception e) { return(CreateErrorPage(e)); } }); var response = new HtmlResponse(); response.ContentType = "text/html; charset=utf-8"; response.Contents = s => { var writer = new StreamWriter(s, Encoding.UTF8); template(writer, model); writer.Flush(); }; return(response); }