package main import ( "html/template" "net/http" "path" ) func displayTmpl(w http.ResponseWriter, page string, vars map[string]interface{}) { t := template.New("index") for _, fname := range []string{ "/static/change.html", "/static/footer.html", "/static/header.html", "/static/login.html", "/static/lost.html", "/static/message.html", "/static/reset.html", } { t.New(path.Base(fname)).Parse(FSMustString(false, fname)) } t.ExecuteTemplate(w, page, vars) } func displayTmplError(w http.ResponseWriter, statusCode int, page string, vars map[string]interface{}) { w.WriteHeader(statusCode) displayTmpl(w, page, vars) } func displayMsg(w http.ResponseWriter, msg string, statusCode int) { w.WriteHeader(statusCode) label := "error" if statusCode < 400 { label = "message" } displayTmpl(w, "message.html", map[string]interface{}{label: msg}) }