}
// RenderErrorBanner renders the error banner. However, this function must ONLY be called by an
// HTMX route. Otherwise, there is no promise it will work (may result in undefined behavior).
// Just writes a piece of content to the response.
+//
+// If this is called from an NON-HTMX request, it will display (and functionality seems to work)
+// but it will be loaded at an unknown position in the DOM. It will not swap with the proper
+// element.
func RenderErrorBanner(ctx *gin.Context, message string) {
- ctx.Writer.Header().Set("Content-Type", "text/html")
- errorBanner(message).Render(ctx.Request.Context(), ctx.Writer)
+ctx.Writer.Header().Set("Content-Type", "text/html")
+errorBanner(message).Render(ctx.Request.Context(), ctx.Writer)
}
diff --git a/internal/templates/components/error_templ.go b/internal/templates/components/error_templ.go
index 607c8e9..5f93b89 100644
--- a/internal/templates/components/error_templ.go
+++ b/internal/templates/components/error_templ.go
@@ -112,7 +112,7 @@ func errorBanner(message string) templ.Component {
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(message)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/components/error.templ`, Line: 46, Col: 13}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/templates/components/error.templ`, Line: 34, Col: 15}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
@@ -129,6 +129,10 @@ func errorBanner(message string) templ.Component {
// RenderErrorBanner renders the error banner. However, this function must ONLY be called by an
// HTMX route. Otherwise, there is no promise it will work (may result in undefined behavior).
// Just writes a piece of content to the response.
+//
+// If this is called from an NON-HTMX request, it will display (and functionality seems to work)
+// but it will be loaded at an unknown position in the DOM. It will not swap with the proper
+// element.
func RenderErrorBanner(ctx *gin.Context, message string) {
ctx.Writer.Header().Set("Content-Type", "text/html")
errorBanner(message).Render(ctx.Request.Context(), ctx.Writer)