2016-07-08 22:40:29 +00:00
|
|
|
package template
|
|
|
|
|
2017-05-12 14:06:01 +00:00
|
|
|
//go:generate togo tmpl -package template -func funcMap -format html -input files/*.html
|
2016-07-08 22:40:29 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"html/template"
|
|
|
|
)
|
|
|
|
|
2017-05-12 14:06:01 +00:00
|
|
|
var funcMap = template.FuncMap{"json": marshal}
|
2017-03-20 15:51:41 +00:00
|
|
|
|
2016-07-08 22:40:29 +00:00
|
|
|
// marshal is a helper function to render data as JSON inside the template.
|
|
|
|
func marshal(v interface{}) template.JS {
|
|
|
|
a, _ := json.Marshal(v)
|
|
|
|
return template.JS(a)
|
|
|
|
}
|