Documentation
¶
Index ¶
- func Coalesce(v1, v2 string) string
- func HxRender(c echo.Context, status int, page, cmp templ.Component) error
- func IIF[T any](condition bool, v1, v2 T) T
- func IsHTMX(c echo.Context) bool
- func Redirect(c echo.Context, status int, route string) error
- func Render(c echo.Context, status int, cmps ...templ.Component) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Coalesce ¶
Coalesce will check if the first value is an empty string and return v2 if it is empty, otherwise it will return v1.
func HxRender ¶
HxRender conditionally renders a component based on whether the request is an HTMX request.
If the request is an HTMX request, it renders the `cmp` component. Otherwise, it renders the `page` component.
func IsHTMX ¶
IsHTMX checks if the request is an HTMX request.
It returns true if the request contains the "HX-Request" header, otherwise, it returns false.
func Redirect ¶
Redirect performs an HTTP redirect, with special handling for HTMX requests.
For HTMX requests, the "HX-Redirect" header is set with the route, and a 200 OK status is used. HTMX does not handle 3xx redirects, it only sees the final 2xx, 4xx, or 5xx response. For non-HTMX requests, a standard HTTP redirect is performed with the provided status.
See github.com/bigskysoftware/htmx/issues/2052#issuecomment-1979805051 for more details.
Types ¶
This section is empty.