-
Notifications
You must be signed in to change notification settings - Fork 0
/
funcmap.go
34 lines (29 loc) · 874 Bytes
/
funcmap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package djangolang
import (
"sync"
"text/template"
"github.com/lflxp/djangolang/components"
"github.com/lflxp/djangolang/consted"
)
var (
once sync.Once
FuncMap template.FuncMap
)
func init() {
once.Do(func() {
if FuncMap == nil {
FuncMap = map[string]interface{}{}
}
})
// 注册自定义函数
FuncMap["beegoli"] = components.NewComponentAdaptor(consted.BeegoLi).Transfer()
FuncMap["admincolumns"] = components.NewComponentAdaptor(consted.AdminColumns).Transfer()
FuncMap["formcolumns"] = components.NewComponentAdaptor(consted.FormComponent).Transfer()
FuncMap["str2html"] = components.NewComponentAdaptor(consted.StrToHtml).Transfer()
FuncMap["uploads"] = components.NewComponentAdaptor(consted.Upload).Transfer()
}
func AddFuncMap(funcName string, funcs interface{}) {
if _, ok := FuncMap[funcName]; !ok {
FuncMap[funcName] = funcs
}
}