htmx

package
v0.0.0-...-b28c917 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

htmx package provides helpers to read htmx headers from http.Request and add htmx headers to http.ResponseWriter.

It embeds a filesystem with the latest build of htmx, minified. The filesystem is exposed via FS() for convenience, although it might move to somewhere else or removed altogether in the future without prior notice.

Index

Constants

View Source
const (

	// HeaderRequest indicates if the request was made by htmx.
	HeaderRequest = "HX-Request"

	// HeaderTriggerName is the name of the element that triggered the request.
	HeaderTriggerName = "HX-Trigger-Name"

	// HeaderTarget is the ID of the target element.
	HeaderTarget = "HX-Target"

	// HeaderPrompt is the value entered by the user when prompted via `hx-prompt`.
	HeaderPrompt = "HX-Prompt"

	// HeaderPush pushes a new URL into the browser's address bar.
	HeaderPush = "HX-Push"

	// HeaderRedirect triggers a client-side redirect to a new location.
	HeaderRedirect = "HX-Redirect"

	// HeaderLocation triggers a client-side redirect to a new location that acts as a swap.
	HeaderLocation = "HX-Location"

	// HeaderRefresh triggers a client-side full refresh of the page when set to `true`.
	HeaderRefresh = "HX-Refresh"

	// HeaderTriggerAfterSwap riggers client-side events after the swap step.
	// See also: https://htmx.org/headers/hx-trigger/
	HeaderTriggerAfterSwap = "HX-Trigger-After-Swap"

	// HeaderTriggerAfterSettle triggers client-side events after the settle step.
	// See also: https://htmx.org/headers/hx-trigger/
	HeaderTriggerAfterSettle = "HX-Trigger-After-Settle"

	// HeaderTrigger is the ID of the element that triggered the request. If set in a response, triggers client-side events.
	// See also: https://htmx.org/headers/hx-trigger/
	HeaderTrigger = "HX-Trigger"
)

Variables

This section is empty.

Functions

func FS

func FS() fs.FS

FS provides a filesystem containing the latest build of htmx, minified. This method must not be relied on and might get removed from this package in the future without prior notice.

func IsRequest

func IsRequest(r *http.Request) bool

IsRequest indicates if a http.Request comes from htmx by checking if the HeaderRequest is present and equals to "true".

func Prompt

func Prompt(r *http.Request) string

func SetLocation

func SetLocation(w http.ResponseWriter, location string)

func SetPush

func SetPush(w http.ResponseWriter, push bool)

func SetRedirect

func SetRedirect(w http.ResponseWriter, location string)

func SetRefresh

func SetRefresh(w http.ResponseWriter, refresh bool)

func SetTrigger

func SetTrigger(w http.ResponseWriter, trigger string)

TODO(@wtfiscrq): implement SetTrigger

func SetTriggerDetails

func SetTriggerDetails(w http.ResponseWriter, trigger string, details any)

TODO(@wtfiscrq): implement SetTriggerDetails

func Target

func Target(r *http.Request) string

func Trigger

func Trigger(r *http.Request) string

func TriggerName

func TriggerName(r *http.Request) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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