Use esc to embed static assets

This commit is contained in:
Pierre-Olivier Mercier
2018-12-30 13:21:30 +01:00
parent 1d3ad672cb
commit 7226e9f1e2
3 changed files with 15 additions and 13 deletions

16
tmpl.go
View File

@@ -7,11 +7,19 @@ import (
)
func displayTmpl(w http.ResponseWriter, page string, vars map[string]interface{}) {
if t, err := template.ParseGlob(path.Join(StaticDir, "*.html")); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
} else {
t.ExecuteTemplate(w, page, vars)
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{}) {