Commit 33725433 authored by Robert Griesemer's avatar Robert Griesemer

godoc: minor fixes

- 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
parent 72ddc876
......@@ -540,7 +540,19 @@ func readTemplate(name string) *template.Template {
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 (
......
......@@ -250,8 +250,8 @@ func main() {
fsHttp = NewHttpZipFS(rc, *goroot)
}
initHandlers()
readTemplates()
initHandlers()
if *httpAddr != "" {
// HTTP server mode.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment