1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-23 03:45:56 +00:00

Replace panic with a message when MustRender fails

This commit is contained in:
Gerasimos Maropoulos
2016-10-15 20:48:06 +03:00
parent 9a0ef4822c
commit 89abc3349d
3 changed files with 25 additions and 1 deletions

View File

@@ -72,6 +72,10 @@ func (t *templateEngines) usePreRender(pre PreRender) {
// the gzip and charset options are built'n with iris
// template is passed as file or souce
func (t *templateEngines) render(isFile bool, ctx *Context, filenameOrSource string, binding interface{}, options []map[string]interface{}) error {
if ctx.framework.Config.DisableTemplateEngines {
return errTemplateExecute.Format("Templates are disabled '.Config.DisableTemplatesEngines = true' please turn that to false, as defaulted.")
}
if len(t.prerenders) > 0 {
for i := range t.prerenders {
// I'm not making any checks here for performance reasons, means that
@@ -114,6 +118,7 @@ func (t *templateEngines) render(isFile bool, ctx *Context, filenameOrSource str
} else {
out = ctx.Response.BodyWriter()
}
if isFile {
return t.ExecuteWriter(out, filenameOrSource, binding, options...)
}