lishwist/http/templates/templates.go
2025-12-11 14:21:12 +09:00

50 lines
915 B
Go

package templates
import (
"html/template"
"lishwist/http/props/htmlx"
)
type AccountLink struct {
Alert bool
}
type CopyList struct {
Domain string
Reference string
}
type User struct {
Name string
CopyList *CopyList
}
type NavCollapse struct {
User *User `json:",omitempty"`
AccountLink *AccountLink `json:",omitempty"`
Links []htmlx.Link
}
func DefaultNavCollapse() NavCollapse {
return NavCollapse{Links: []htmlx.Link{{Href: "/", Name: "Home"}}}
}
func UserNavCollapse(username string, accountAlert bool) NavCollapse {
return NavCollapse{
Links: []htmlx.Link{{Href: "/", Name: "Home"}},
User: &User{Name: username},
AccountLink: &AccountLink{Alert: accountAlert},
}
}
var Template *template.Template
func init() {
Template = load()
}
func load() *template.Template {
t := template.Must(template.ParseGlob("templates/*.gotmpl"))
return t
}