Skip to main content

Module htmx

Module htmx 

Source
Expand description

Standard HTMX 2 helpers for HX-* headers, hx-swap-oob fragments, and signed flash cookies.

Functionsยง

flash_redirect
Set a signed Flash cookie and return 303 See Other with both Location and HX-Redirect.
is_htmx
Return true when the request carries HX-Request: true.
oob
Wrap inner in an HTMX out-of-band swap container (hx-swap-oob).
oob_delete
Emit an HTMX out-of-band delete instruction (hx-swap-oob="delete") for target_id.
oob_replace
Emit an HTMX out-of-band outerHTML swap targeting target_id.
redirect
Return a 200 OK response with HX-Redirect so HTMX performs a full navigation.
set_flash
Store a signed, 60-second expiring one-shot Flash message in the slabs_flash cookie (HttpOnly, SameSite=Lax, Path=/, Max-Age=60).
take_flash
Read and verify the signed slabs_flash cookie, removing it from jar if present.
wants_json
Return true when the Accept header contains application/json.
with_trigger
Return a 200 OK HTML fragment with an HX-Trigger client event header.