From 6b030adf02dd2dfbe722527eeb302e53b529bd87 Mon Sep 17 00:00:00 2001 From: Hayden Hargreaves Date: Wed, 3 Sep 2025 22:25:13 -0700 Subject: [PATCH] (DOC): Updated documentation --- internal/templates/components/error.templ | 72 +++++++++----------- internal/templates/components/error_templ.go | 6 +- 2 files changed, 37 insertions(+), 41 deletions(-) diff --git a/internal/templates/components/error.templ b/internal/templates/components/error.templ index 7c75b50..7df6acf 100644 --- a/internal/templates/components/error.templ +++ b/internal/templates/components/error.templ @@ -3,56 +3,48 @@ package components import "github.com/gin-gonic/gin" templ errorIcon() { - - - + + + } templ closeButton() { - + } templ errorBanner(message string) { -
-
- @errorIcon() -

Error

- @closeButton() -
-
-

- { message } -

-
-
+
+
+ @errorIcon() +

Error

+ @closeButton() +
+
+

+ { message } +

+
+
} // 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)