MCPcopy
hub / github.com/tailscale/golink / newTemplate

Function newTemplate

golink.go:319–329  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

317// and tmplFuncs are registered as available funcs.
318// This func panics if unable to parse files.
319func 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.
332func initStats() error {

Callers 1

initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected