newTemplate creates a new template with the specified files in the tmpl directory. The first file name is used as the template name, and tmplFuncs are registered as available funcs. This func panics if unable to parse files.
(files ...string)
| 317 | // and tmplFuncs are registered as available funcs. |
| 318 | // This func panics if unable to parse files. |
| 319 | func newTemplate(files ...string) *template.Template { |
| 320 | if len(files) == 0 { |
| 321 | return nil |
| 322 | } |
| 323 | tf := make([]string, 0, len(files)) |
| 324 | for _, f := range files { |
| 325 | tf = append(tf, "tmpl/"+f) |
| 326 | } |
| 327 | t := template.New(files[0]).Funcs(tmplFuncs) |
| 328 | return template.Must(t.ParseFS(embeddedFS, tf...)) |
| 329 | } |
| 330 | |
| 331 | // initStats initializes the in-memory stats counter with counts from db. |
| 332 | func initStats() error { |