1
0

Removed old template pre-compilation. Added go:generate command to create an index.jade.go file.

This commit is contained in:
Alexander Andreev 2022-06-13 18:39:30 +04:00
parent 595d7769ec
commit 5be38c00cf
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -1,15 +1,13 @@
package web package web
import ( import (
"dwelling-radio/pkg/logging"
"embed" "embed"
"html/template"
"io/fs" "io/fs"
"net/http" "net/http"
"github.com/Joker/jade"
) )
//go:generate /home/arav/go/bin/jade -pkg=web -writer templates/index.jade
//go:embed assets //go:embed assets
var assetsDir embed.FS var assetsDir embed.FS
@ -21,19 +19,3 @@ func Assets() http.FileSystem {
func AssetsGetFile(path string) ([]byte, error) { func AssetsGetFile(path string) ([]byte, error) {
return assetsDir.ReadFile("assets/" + path) return assetsDir.ReadFile("assets/" + path)
} }
//go:embed templates/index.jade
var indexJadeTpl []byte
var IndexTemplate *template.Template
func CompileTemplates(lErr *logging.Logger) {
indexParsedTpl, err := jade.Parse("index", indexJadeTpl)
if err != nil {
lErr.Fatalln(err)
}
IndexTemplate, err = template.New("index").Parse(indexParsedTpl)
if err != nil {
lErr.Fatalln(err)
}
}