1
0
dwelling-radio/web/web.go

40 lines
706 B
Go
Raw Normal View History

package web
import (
"dwelling-radio/pkg/logging"
"embed"
"html/template"
"io/fs"
"net/http"
"github.com/Joker/jade"
)
//go:embed assets
var assetsDir embed.FS
func Assets() http.FileSystem {
f, _ := fs.Sub(assetsDir, "assets")
return http.FS(f)
}
func AssetsGetFile(path string) ([]byte, error) {
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)
}
}