Commit d71d11fa authored by Andrew Gerrand's avatar Andrew Gerrand

cmd/godoc: use virtual filesystem to implement -templates flag

R=golang-dev, gri, rsc
CC=golang-dev
https://golang.org/cl/5921045
parent 5eb007de
...@@ -491,14 +491,6 @@ var fmap = template.FuncMap{ ...@@ -491,14 +491,6 @@ var fmap = template.FuncMap{
func readTemplate(name string) *template.Template { func readTemplate(name string) *template.Template {
path := "lib/godoc/" + name path := "lib/godoc/" + name
if *templateDir != "" {
defaultpath := path
path = pathpkg.Join(*templateDir, name)
if _, err := fs.Stat(path); err != nil {
log.Print("readTemplate:", err)
path = defaultpath
}
}
// use underlying file system fs to read the template file // use underlying file system fs to read the template file
// (cannot use template ParseFile functions directly) // (cannot use template ParseFile functions directly)
......
...@@ -167,6 +167,9 @@ func main() { ...@@ -167,6 +167,9 @@ func main() {
if *zipfile == "" { if *zipfile == "" {
// use file system of underlying OS // use file system of underlying OS
fs.Bind("/", OS(*goroot), "/", bindReplace) fs.Bind("/", OS(*goroot), "/", bindReplace)
if *templateDir != "" {
fs.Bind("/lib/godoc", OS(*templateDir), "/", bindBefore)
}
} else { } else {
// use file system specified via .zip file (path separator must be '/') // use file system specified via .zip file (path separator must be '/')
rc, err := zip.OpenReader(*zipfile) rc, err := zip.OpenReader(*zipfile)
......
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