21 lines
334 B
Go
21 lines
334 B
Go
package format
|
|
|
|
import (
|
|
"encoding/json"
|
|
"text/template"
|
|
)
|
|
|
|
var TemplateFuncMap = template.FuncMap{
|
|
"add": func(a, b int) int {
|
|
return a + b
|
|
},
|
|
"json_decode": func(o interface{}) interface{} {
|
|
var r []map[string]interface{}
|
|
err := json.Unmarshal([]byte(o.(string)), &r)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return r
|
|
},
|
|
}
|