27 lines
458 B
Go
27 lines
458 B
Go
|
package funcmap
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"strings"
|
||
|
"text/template"
|
||
|
)
|
||
|
|
||
|
var FuncMap = template.FuncMap{
|
||
|
"json": func(v interface{}) string {
|
||
|
a, _ := json.Marshal(v)
|
||
|
return string(a)
|
||
|
},
|
||
|
"prettyjson": func(v interface{}) string {
|
||
|
a, _ := json.MarshalIndent(v, "", " ")
|
||
|
return string(a)
|
||
|
},
|
||
|
// yaml
|
||
|
// xml
|
||
|
// toml
|
||
|
"split": strings.Split,
|
||
|
"join": strings.Join,
|
||
|
"title": strings.Title,
|
||
|
"lower": strings.ToLower,
|
||
|
"upper": strings.ToUpper,
|
||
|
}
|