htmx

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HXBoosted indicates the request is an HTMX boosted request.
	HXBoosted = "HX-Boosted"

	// HXCurrentURL is the current URL of the browser
	HXCurrentURL = "HX-Current-URL"

	// HXHistoryRestoreRequest indicates the request is a history restore request due to a miss in the local history cache
	HXHistoryRestoreRequest = "HX-History-Restore-Request"

	// HXPrompt is the user response to an hx-prompt
	HXPrompt = "HX-Prompt"

	// HXRequest indicates the request is an HTMX request
	HXRequest = "HX-Request"

	// HXTarget is the ID of the target element, if any
	HXTarget = "HX-Target"

	// HXTriggerName is the name of the triggered element
	HXTriggerName = "HX-Trigger-Name"
)

HTMX Request Headers

View Source
const (
	// HXLocation allows you to do a client-side redirect without a full page reload (similar to a boost)
	HXLocation = "HX-Location"

	// HXPushURL pushes the URL into the browser history stack
	HXPushURL = "HX-Push-URL"

	// HXRedirect allows you to do a client-side redirect as a full page reload
	HXRedirect = "HX-Redirect"

	// HXRefresh allows you to refresh the page as a full page reload
	HXRefresh = "HX-Refresh"

	// HXReplaceURL replaces the URL in the browser location bar
	HXReplaceURL = "HX-Replace-URL"

	// HXReswap allows you to specify how the response will be swapped in by HTMX
	HXReswap = "HX-Reswap"

	// HXRetarget is a CSS selector that updates the target of the content to update by HTMX
	HXRetarget = "HX-Retarget"

	// HXReselect is a CSS selector that indicates which part of the response should be swapped in. Overrides existing hx-swap values on the triggering element.
	HXReselect = "HX-ReSelect"

	// HXTriggerAfterSettle allows you to trigger client-side-events after the settle phase
	HXTriggerAfterSettle = "HX-Trigger-After-Settle"

	// HXTriggerAfterSwap allows you to trigger client-side-events after the swap phase
	HXTriggerAfterSwap = "HX-Trigger-After-Swap"
)

HTMX Response Headers

View Source
const (
	// HXTrigger is the ID of the triggered element when used in a request. As a response header, it can be used to trigger client-side events.
	HXTrigger = "HX-Trigger"
)

Dual-use Headers (request and response)

Variables

This section is empty.

Functions

func CurrentURL

func CurrentURL(r *http.Request) (string, bool)

CurrentURL returns the HX-Current-URL header, if it exists

func IsAnyHtmxRequest

func IsAnyHtmxRequest(r *http.Request) bool

IsAnyHtmxRequest returns true if the current request is either an HX/HTMX request or boosted.

func IsBoostedRequest

func IsBoostedRequest(r *http.Request) bool

IsBoostedRequest returns true if the current request is boosted by the HX-Boosted header.

func IsHistoryRestoreRequest

func IsHistoryRestoreRequest(r *http.Request) bool

IsHistoryRestoreRequest returns true if the current request contains the HX-History-Restore header

func IsHtmxRequest

func IsHtmxRequest(r *http.Request) bool

IsHtmxRequest returns true if the current request is an HX/HTMX request, but not boosted. This distinguishes between a standard HTMX request and a boosted request as the server may need to differentiate between the two. HTMX sends a HX-Request header along with HX-Boosted, so it is not enough to check the HX-Request header.

func Prompt

func Prompt(r *http.Request) (string, bool)

Prompt returns the HX-Prompt header, if it exists

func Target

func Target(r *http.Request) (string, bool)

Target returns the HX-Target header, if it exists

func Trigger

func Trigger(r *http.Request) (string, bool)

Trigger returns the HX-Trigger header, if it exists

func TriggerName

func TriggerName(r *http.Request) (string, bool)

TriggerName returns the HX-Trigger-Name header, if it exists

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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