mirror of
https://github.com/kataras/iris.git
synced 2026-01-06 03:27:27 +00:00
examples: add an example for #2019
This commit is contained in:
16
view/view.go
16
view/view.go
@@ -2,6 +2,7 @@ package view
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
@@ -76,6 +77,21 @@ func (v *View) AddFunc(funcName string, funcBody interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// Funcs registers a template func map to the registered view engine(s).
|
||||
func (v *View) Funcs(m template.FuncMap) *View {
|
||||
if !v.Registered() {
|
||||
return v
|
||||
}
|
||||
|
||||
if e, ok := v.Engine.(EngineFuncer); ok {
|
||||
for k, v := range m {
|
||||
e.AddFunc(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Load compiles all the registered engines.
|
||||
func (v *View) Load() error {
|
||||
if !v.Registered() {
|
||||
|
||||
Reference in New Issue
Block a user