Use go-bindata instead of esc

This commit is contained in:
nemunaire 2020-09-02 15:25:34 +02:00
parent b8d9118b56
commit cd8d7388a6
3 changed files with 9 additions and 16 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
chldapasswd
config.json
static.go
bindata.go

View File

@ -1,6 +1,5 @@
package main
//go:generate esc -o static.go static
import (
"context"
"encoding/json"

View File

@ -1,25 +1,19 @@
package main
//go:generate go-bindata -ignore "\\.go|\\.less" -pkg "main" -o "bindata.go" static/...
//go:generate go fmt bindata.go
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)
data := MustAsset("static/" + page)
tpl := template.Must(template.New("page").Parse(string(data)))
tpl.New("footer.html").Parse(string(MustAsset("static/footer.html")))
tpl.New("header.html").Parse(string(MustAsset("static/header.html")))
tpl.ExecuteTemplate(w, "page", vars)
}
func displayTmplError(w http.ResponseWriter, statusCode int, page string, vars map[string]interface{}) {