mirror of
https://github.com/golang/go
synced 2024-11-21 17:54:39 -07:00
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
This commit is contained in:
parent
72ddc87681
commit
337254333f
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user