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:
- Request accessors (
hx_request,hx_boosted,hx_target, …) read the htmx request headers from acx: &Cx. - Responders (
HxRedirect,HxRefresh,HxRetarget,HxResponseTrigger, …) implementIntoResponseParts, so they can be placed before the body in a handler’s response tuple to set the corresponding htmx response headers.
The raw header names are available as constants in the header module.
Modules§
- header
- The htmx HTTP header names, as
HeaderNameconstants.
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-Locationheader. - HxPush
Url - Pushes a new URL onto the browser history stack via the
HX-Push-Urlheader. - HxRedirect
- Performs a client-side redirect to a new location via the
HX-Redirectheader. - HxRefresh
- Triggers a full client-side page refresh via the
HX-Refreshheader whentrue. - HxReplace
Url - Replaces the current URL in the location bar via the
HX-Replace-Urlheader. - HxReselect
- Chooses which part of the response is swapped in via the
HX-Reselectheader, overriding an existinghx-select. The value is a CSS selector. - HxResponse
Trigger - Triggers client-side events via one of the
HX-Triggerresponse headers. - HxReswap
- Overrides how the response is swapped in via the
HX-Reswapheader. SeeSwapOption. - HxRetarget
- Retargets the content update to a different element via the
HX-Retargetheader. The value is a CSS selector. - Location
Options - The optional context of an
HxLocation.
Enums§
- Swap
Option - How htmx swaps a response into the DOM.
- Trigger
Timing - When htmx triggers the events of an
HxResponseTrigger.
Functions§
- hx_
boosted - Returns
truewhen the request was made by an element usinghx-boost, i.e. it carriesHX-Boosted: true. - hx_
current_ url - Returns the current browser URL from the
HX-Current-URLheader, orNonewhen it is absent. - hx_
history_ restore_ request - Returns
truewhen the request restores history after a miss in the local history cache, i.e. it carriesHX-History-Restore-Request: true. - hx_
prompt - Returns the user’s response to an
hx-promptfrom theHX-Promptheader, orNonewhen there was no prompt. - hx_
request - Returns
truewhen the current request was issued by htmx, i.e. it carries anHX-Request: trueheader. - hx_
target - Returns the
idof the target element from theHX-Targetheader, orNonewhen the request has no target. - hx_
trigger - Returns the
idof the triggering element from theHX-Triggerheader, orNonewhen it has none. - hx_
trigger_ name - Returns the
nameof the triggering element from theHX-Trigger-Nameheader, orNonewhen it has none.