Commits

Josh Rickmar committed 16ce3de

Make tmplParser a global var and reuse it for each file instead of
creating a new one each time.

Comments (0)

Files changed (1)

 	ignoreRegExp = flag.String(`ignore`, ``, `ignore regexp`)
 	tmplFlag     = flag.String(`tmpl`, ``, `template file`)
 	mdParser     = markdown.NewParser(&markdown.Extensions{Smart: true})
+	tmplParser   *template.Template
 )
 
 type Navigation struct {
 		}
 	}
 
+	tmplParser, err = template.ParseFiles(*tmplFlag)
+	if err != nil {
+		panic(err)
+	}
+
 	filepath.Walk(filepath.Base(*dirFlag), mkPage)
 	os.Exit(0)
 }
 		SubTitle: *subtitleFlag,
 		CSS:      `/style.css`,
 	}
-	p, err := template.ParseFiles(*tmplFlag)
-	if err != nil {
-		panic(err)
-	}
 
 	/* XXX: index and navitems
 	dir, err := os.Open(filepath.Dir(srcPath))
 		buf := new(bytes.Buffer)
 		mdParser.Markdown(src, markdown.ToHTML(buf))
 		pageElems.Main = template.HTML(buf.String())
-		p.Execute(dest, pageElems)
+		tmplParser.Execute(dest, pageElems)
 	default:
 		io.Copy(dest, src)
 	}