aboutsummaryrefslogtreecommitdiff
path: root/index.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-02-17 07:54:30 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-02-17 07:54:30 +0100
commit45c9fdd5279e926c629c4e4fe3fd81b61c9c40dd (patch)
treebe3ddff8cd249a89779bac38c73a060d52f0e0b7 /index.go
parenta57064fa2a6c8c5ca41713dbc9541f0cca4cfe27 (diff)
Parse template once
Diffstat (limited to 'index.go')
-rw-r--r--index.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/index.go b/index.go
index 14f0ca9..10160ab 100644
--- a/index.go
+++ b/index.go
@@ -10,6 +10,8 @@ func init() {
http.HandleFunc("/index", indexHandler)
}
+var indextmpl = template.Must(template.ParseFiles("tmpl/root", "tmpl/index"))
+
func indexHandler(w http.ResponseWriter, r *http.Request) {
files, err := ioutil.ReadDir("data")
if err != nil {
@@ -23,5 +25,5 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
p.Pages = append(p.Pages, entry)
}
}
- p.render(w, template.Must(template.ParseFiles("tmpl/root", "tmpl/index")))
+ p.render(w, indextmpl)
}