protoc-gen-go-micro/vendor/github.com/moul/funcmap/funcmap.go

27 lines
458 B
Go
Raw Normal View History

2016-11-06 20:32:32 +03:00
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,
}