Use go-bindata instead of esc
This commit is contained in:
parent
b8d9118b56
commit
cd8d7388a6
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
|||||||
chldapasswd
|
chldapasswd
|
||||||
config.json
|
config.json
|
||||||
static.go
|
bindata.go
|
1
main.go
1
main.go
@ -1,6 +1,5 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
//go:generate esc -o static.go static
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
@ -1,25 +1,19 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
//go:generate go-bindata -ignore "\\.go|\\.less" -pkg "main" -o "bindata.go" static/...
|
||||||
|
//go:generate go fmt bindata.go
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func displayTmpl(w http.ResponseWriter, page string, vars map[string]interface{}) {
|
func displayTmpl(w http.ResponseWriter, page string, vars map[string]interface{}) {
|
||||||
t := template.New("index")
|
data := MustAsset("static/" + page)
|
||||||
for _, fname := range []string{
|
tpl := template.Must(template.New("page").Parse(string(data)))
|
||||||
"/static/change.html",
|
tpl.New("footer.html").Parse(string(MustAsset("static/footer.html")))
|
||||||
"/static/footer.html",
|
tpl.New("header.html").Parse(string(MustAsset("static/header.html")))
|
||||||
"/static/header.html",
|
tpl.ExecuteTemplate(w, "page", vars)
|
||||||
"/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{}) {
|
func displayTmplError(w http.ResponseWriter, statusCode int, page string, vars map[string]interface{}) {
|
Loading…
Reference in New Issue
Block a user