package views import "git.32bit.cafe/32bitcafe/guestbook/internal/models" import "strconv" import "fmt" import "strings" type CommonData struct { CurrentYear int Flash string IsAuthenticated bool CSRFToken string CurrentUser *models.User IsHtmx bool } func shortIdToSlug(shortId uint64) string { return strconv.FormatUint(shortId, 36) } func slugToShortId(slug string) uint64 { id, _ := strconv.ParseUint(slug, 36, 64) return id } func externalUrl(url string) string { if !strings.HasPrefix(url, "http") { return "http://" + url } return url } templ commonHeader() {

webweav.ing

} templ topNav(data CommonData) { {{ hxHeaders := fmt.Sprintf("{\"X-CSRF-Token\": \"%s\"}", data.CSRFToken) }} } templ commonFooter() { } templ base(title string, data CommonData) { { title } - webweav.ing @commonHeader() @topNav(data)
if data.Flash != "" {
{ data.Flash }
} { children... }
@commonFooter() }