htmx

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2025 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HXBoosted               = "HX-Boosted"                 // indicates that the request is via an element using hx-boost
	HXCurrentURL            = "HX-Current-URL"             // the current URL of the browser
	HXHistoryRestoreRequest = "HX-History-Restore-Request" // “true” if the request is for history restoration after a miss in the local history cache
	HXPrompt                = "HX-Prompt"                  // the user response to an hx-prompt
	HXRequest               = "HX-Request"                 // always “true”
	HXtarget                = "HX-Target"                  // the id of the target element if it exists
	HXTriggerName           = "HX-Trigger-Name"            // the name of the triggered element if it exists
)

HTMX Request Headers

View Source
const (
	HXLocation           = "HX-Location"             // allows you to do a client-side redirect that does not do a full page reload
	HxPushURL            = "HX-Push-Url"             // pushes a new url into the history stack
	HXRedirect           = "HX-Redirect"             // can be used to do a client-side redirect to a new location
	HXRefresh            = "HX-Refresh"              // if set to “true” the client-side will do a full refresh of the page
	HXReplaceURL         = "HX-Replace-Url"          // replaces the current URL in the location bar
	HXReswap             = "HX-Reswap"               // allows you to specify how the response will be swapped. See hx-swap for possible values
	HXRetarget           = "HX-Retarget"             //a CSS selector that updates the target of the content update to a different element on the page
	HXReselect           = "HX-Reselect"             // a CSS selector that allows you to choose which part of the response is used to be swapped in. Overrides an existing hx-select on the triggering element
	HXTriggerAfterSettle = "HX-Trigger-After-Settle" // allows you to trigger client-side events after the settle step
	HXTriggerAfterSwap   = "HX-Trigger-After-Swap"   // allows you to trigger client-side events after the swap step
)

HTMX Response Headers

View Source
const HXTrigger = "HX-Trigger" // the id of the triggered element if it exists in requests, allows you to trigger client-side events in responses

HXTrigger is both a request and a response header

Variables

This section is empty.

Functions

func IsHTMXRequest

func IsHTMXRequest(c *gin.Context) bool

func Redirect

func Redirect(c *gin.Context, code int, location string)

Redirect determines if the request is an HTMX request, if so, it sets the HX-Redirect header and returns a 204 no content to allow HTMX to handle the redirect. Otherwise it sets the code and issues a normal gin redirect with the location in the headers.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL