Skip to main content

Crate topcoat_htmx

Crate topcoat_htmx 

Source
Expand description

htmx support for Topcoat.

This crate provides two halves of htmx integration, both built on Topcoat’s request context and response conventions rather than on extractors and middleware:

The raw header names are available as constants in the header module.

Modules§

header
The htmx HTTP header names, as HeaderName constants.

Structs§

HxEvent
A client-side event for htmx to trigger, optionally carrying a JSON detail.
HxLocation
Performs a client-side redirect that does not trigger a full page reload, via the HX-Location header.
HxPushUrl
Pushes a new URL onto the browser history stack via the HX-Push-Url header.
HxRedirect
Performs a client-side redirect to a new location via the HX-Redirect header.
HxRefresh
Triggers a full client-side page refresh via the HX-Refresh header when true.
HxReplaceUrl
Replaces the current URL in the location bar via the HX-Replace-Url header.
HxReselect
Chooses which part of the response is swapped in via the HX-Reselect header, overriding an existing hx-select. The value is a CSS selector.
HxResponseTrigger
Triggers client-side events via one of the HX-Trigger response headers.
HxReswap
Overrides how the response is swapped in via the HX-Reswap header. See SwapOption.
HxRetarget
Retargets the content update to a different element via the HX-Retarget header. The value is a CSS selector.
LocationOptions
The optional context of an HxLocation.

Enums§

SwapOption
How htmx swaps a response into the DOM.
TriggerTiming
When htmx triggers the events of an HxResponseTrigger.

Functions§

hx_boosted
Returns true when the request was made by an element using hx-boost, i.e. it carries HX-Boosted: true.
hx_current_url
Returns the current browser URL from the HX-Current-URL header, or None when it is absent.
hx_history_restore_request
Returns true when the request restores history after a miss in the local history cache, i.e. it carries HX-History-Restore-Request: true.
hx_prompt
Returns the user’s response to an hx-prompt from the HX-Prompt header, or None when there was no prompt.
hx_request
Returns true when the current request was issued by htmx, i.e. it carries an HX-Request: true header.
hx_target
Returns the id of the target element from the HX-Target header, or None when the request has no target.
hx_trigger
Returns the id of the triggering element from the HX-Trigger header, or None when it has none.
hx_trigger_name
Returns the name of the triggering element from the HX-Trigger-Name header, or None when it has none.