blob: 2769926b294fa44c58165976769d4843a3db7215 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package main
import (
"log"
"net/http"
"text/template"
)
func setupTemplates() *template.Template {
t, err := template.ParseGlob(config.Templates + "/*.html")
if err != nil {
panic(err)
}
return t
}
func ServeTemplate(w http.ResponseWriter, name string, data interface{}) {
err := templates.ExecuteTemplate(w, name, data)
if err != nil {
log.Print(err)
http.Error(w, http.StatusText(404), 404)
return
}
}
|