- templates should be read before any handlers are started
- for app engine use, must use underlying file system to read templates
R=r
CC=golang-dev
https://golang.org/cl/
4928042
path = defaultpath
}
}
- return template.Must(template.New(name).Funcs(fmap).ParseFile(path))
+
+ // use underlying file system fs to read the template file
+ // (cannot use template ParseFile functions directly)
+ data, err := fs.ReadFile(path)
+ if err != nil {
+ log.Fatal("readTemplate: ", err)
+ }
+ // be explicit with errors (for app engine use)
+ t, err := template.New(name).Funcs(fmap).Parse(string(data))
+ if err != nil {
+ log.Fatal("readTemplate: ", err)
+ }
+ return t
}
var (
fsHttp = NewHttpZipFS(rc, *goroot)
}
- initHandlers()
readTemplates()
+ initHandlers()
if *httpAddr != "" {
// HTTP server mode.