1
0
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:
Gerasimos (Makis) Maropoulos
2022-12-17 01:16:10 +02:00
parent 1ea5cd58be
commit de8883fc98
6 changed files with 58 additions and 7 deletions

View File

@@ -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() {