mirror of
https://github.com/kataras/iris.git
synced 2025-12-22 12:27:02 +00:00
Read https://github.com/kataras/iris/tree/master/HISTORY.md
This commit is contained in:
@@ -152,15 +152,11 @@ func getPongoContext(templateData interface{}) pongo2.Context {
|
||||
return nil
|
||||
}
|
||||
|
||||
if v, isMap := templateData.(map[string]interface{}); isMap {
|
||||
return v
|
||||
}
|
||||
|
||||
if contextData, isPongoContext := templateData.(pongo2.Context); isPongoContext {
|
||||
return contextData
|
||||
}
|
||||
|
||||
return nil
|
||||
return templateData.(map[string]interface{})
|
||||
}
|
||||
|
||||
func (p *Engine) fromCache(relativeName string) *pongo2.Template {
|
||||
|
||||
@@ -132,11 +132,23 @@ func RegisterSharedFunc(name string, fn interface{}) {
|
||||
sharedFuncs[name] = fn
|
||||
}
|
||||
|
||||
// RegisterSharedFuncs registers functionalities that should be inherited from all supported template engines
|
||||
func RegisterSharedFuncs(theFuncs map[string]interface{}) {
|
||||
if sharedFuncs == nil || len(sharedFuncs) == 0 {
|
||||
sharedFuncs = theFuncs
|
||||
return
|
||||
}
|
||||
for k, v := range theFuncs {
|
||||
sharedFuncs[k] = v
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Render renders a template using the context's writer
|
||||
func (t *Template) Render(ctx context.IContext, name string, binding interface{}, layout ...string) (err error) {
|
||||
|
||||
if t == nil { // No engine was given but .Render was called
|
||||
ctx.WriteHTML(403, "<b> Iris </b> <br/> Templates are disabled via config.NoEngine, check your iris' configuration please.")
|
||||
ctx.HTML(403, "<b> Iris </b> <br/> Templates are disabled via config.NoEngine, check your iris' configuration please.")
|
||||
return fmt.Errorf("[IRIS TEMPLATES] Templates are disabled via config.NoEngine, check your iris' configuration please.\n")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user