···44 "fmt"
55 "html"
66 "net/http"
77+ "strings"
78)
89910// Notice performs a hx-oob-swap to replace the content of an element with a message.
···2324 w.Header().Set("Content-Type", "text/html")
2425 w.WriteHeader(http.StatusOK)
2526 w.Write([]byte(markup))
2727+}
2828+2929+func (s *Pages) NoticeHTMLWithClears(w http.ResponseWriter, id string, trustedHTML string, clearIDs ...string) {
3030+ var b strings.Builder
3131+ b.WriteString(fmt.Sprintf(`<span id="%s" hx-swap-oob="innerHTML">%s</span>`, id, trustedHTML))
3232+ for _, clearID := range clearIDs {
3333+ b.WriteString(fmt.Sprintf(`<span id="%s" hx-swap-oob="innerHTML"></span>`, clearID))
3434+ }
3535+3636+ w.Header().Set("Content-Type", "text/html")
3737+ w.WriteHeader(http.StatusOK)
3838+ w.Write([]byte(b.String()))
2639}
27402841// HxRefresh is a client-side full refresh of the page.
+2-2
appview/signup/signup.go
···332332 // if we get here, we've successfully created the account and added the email
333333 success = true
334334335335- s.pages.NoticeHTML(w, "signup-msg", fmt.Sprintf(`Account created successfully. You can now
335335+ s.pages.NoticeHTMLWithClears(w, "signup-msg", fmt.Sprintf(`Account created successfully. You can now
336336 <a class="underline text-black dark:text-white" href="/login">login</a>
337337- with <code>%s.tngl.sh</code>.`, username))
337337+ with <code>%s.tngl.sh</code>.`, username), "signup-error")
338338339339 // clean up inflight signup asynchronously
340340 go func() {