Cleaned up conditional rendering.

This commit is contained in:
mikestefanello 2025-03-29 09:40:04 -04:00
parent 02236266f1
commit c8db468292
5 changed files with 71 additions and 56 deletions

View file

@ -27,17 +27,13 @@ func JS(r *ui.Request) Node {
})
`
var csrf Node
if len(r.CSRF) > 0 {
csrf = Script(Raw(fmt.Sprintf(htmxCSRF, r.CSRF)))
}
return Group{
Script(Src("https://unpkg.com/htmx.org@2.0.0/dist/htmx.min.js")),
Script(Src("https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"), Defer()),
Script(Raw(htmxErr)),
csrf,
Iff(len(r.CSRF) > 0, func() Node {
return Script(Raw(fmt.Sprintf(htmxCSRF, r.CSRF)))
}),
}
}