Convert templates to global

The templates will be parsed only on startup
This commit is contained in:
Las Zenow 2012-10-24 21:08:34 +02:00
parent 689be55708
commit 68e999777a

View file

@ -23,20 +23,19 @@ func GetStatus(w http.ResponseWriter, r *http.Request) Status {
return s return s
} }
func loadTemplate(w http.ResponseWriter, tmpl string, data interface{}) { var templates = template.Must(template.ParseFiles(TEMPLATE_PATH+"header.html",
// TODO: when finish devel conver to global: TEMPLATE_PATH+"footer.html",
var templates = template.Must(template.ParseFiles(TEMPLATE_PATH+"header.html", TEMPLATE_PATH+"index.html",
TEMPLATE_PATH+"footer.html", TEMPLATE_PATH+"about.html",
TEMPLATE_PATH+"index.html", TEMPLATE_PATH+"book.html",
TEMPLATE_PATH+"about.html", TEMPLATE_PATH+"search.html",
TEMPLATE_PATH+"book.html", TEMPLATE_PATH+"upload.html",
TEMPLATE_PATH+"search.html", TEMPLATE_PATH+"new.html",
TEMPLATE_PATH+"upload.html", TEMPLATE_PATH+"read.html",
TEMPLATE_PATH+"new.html", TEMPLATE_PATH+"edit.html",
TEMPLATE_PATH+"read.html", ))
TEMPLATE_PATH+"edit.html",
))
func loadTemplate(w http.ResponseWriter, tmpl string, data interface{}) {
err := templates.ExecuteTemplate(w, tmpl+".html", data) err := templates.ExecuteTemplate(w, tmpl+".html", data)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)