22 lines
453 B
Go
22 lines
453 B
Go
package baseTemplates
|
|
|
|
import (
|
|
"embed"
|
|
"html/template"
|
|
"net/http"
|
|
)
|
|
|
|
//go:embed templates/*
|
|
var FS embed.FS
|
|
|
|
func WithBase(w http.ResponseWriter, templateData any, patterns ...string) {
|
|
args := append([]string{"templates/base.tmpl"}, patterns...)
|
|
tmpl := template.Must(template.ParseFS(FS, args...))
|
|
|
|
err := tmpl.ExecuteTemplate(w, "base", templateData)
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
}
|