29 lines
534 B
Go
29 lines
534 B
Go
package web
|
|
|
|
import (
|
|
"embed"
|
|
"net/http"
|
|
"text/template"
|
|
|
|
"github.com/olivere/vite"
|
|
)
|
|
|
|
type PageData struct {
|
|
Title string
|
|
MsgType string
|
|
Message string
|
|
Redirect string
|
|
Vite *vite.Fragment
|
|
}
|
|
|
|
//go:embed templates
|
|
var Templates embed.FS
|
|
|
|
//go:embed frontend/dist
|
|
var StaticAssets embed.FS
|
|
|
|
func RenderTemplate(w http.ResponseWriter, name string, data PageData) error {
|
|
tpl := template.Must(template.ParseFS(Templates, "templates/"+name+".html", "templates/base.html"))
|
|
return tpl.ExecuteTemplate(w, "base", data)
|
|
}
|