Documentation
¶
Index ¶
- Constants
- func ActionClipboard(data string) string
- func ActionSetAll(paths string, value string) string
- func ActionToggle(paths string) string
- func Delete(url string, opts ...Options) string
- func Get(url string, opts ...Options) string
- func Join(parts ...string) string
- func OnEnterKey(actions ...string) string
- func Patch(url string, opts ...Options) string
- func Post(url string, opts ...Options) string
- func Put(url string, opts ...Options) string
- type Options
Constants ¶
const FilterEnterKey = "evt.key == 'Enter'"
FilterEnterKey filters keyboard inputs with that have Enter key pressed. This allows html text inputs to run actions on Enter.
Variables ¶
This section is empty.
Functions ¶
func ActionClipboard ¶
Copies the provided evaluated expression to the clipboard.
func ActionSetAll ¶
Sets the value of all matching signals to the expression provided in the second argument. The first argument accepts one or more space-separated signal paths. You can use * to match a single path segment and ** to match multiple path segments.
func ActionToggle ¶
Toggles the value of all matching signals. The first argument accepts one or more space-separated signal paths. You can use * to match a single path segment and ** to match multiple path segments.
func Get ¶
Sends a GET request to the backend using fetch, and merges the response with the current DOM and signals. The URL can be any valid URL and the response must contain zero or more Datastar SSE events.
func OnEnterKey ¶
OnEnterKey applies FilterEnterKey to a set of actions.
Types ¶
type Options ¶
type Options struct {
// Query allows to set additional url query to send to server.
Query map[string]any
// Sets contentType to 'form'.
Form bool
// Specifies a form to send when Form == true.
FormSelector string
// Specifies whether to include local signals (those beggining with an underscore) in the request.
IncludeLocal bool
// An map containing headers to send with the request.
Headers map[string]string
// Specifies whether to keep the connection open when the page is hidden. Useful for dashboards but can cause a drain on battery life and other resources when enabled.
KeepOpen bool
// The retry interval.
RetryInterval time.Duration
// A numeric multiplier applied to scale retry wait times.
RetryScaler int
// The maximum allowable wait time between retries.
RetryMaxWait time.Duration
// The maximum number of retry attempts.
RetryMaxCount int
}
Options contain options for datastar url actions.
Refer to datastar docs for details: https://data-star.dev/reference/action_plugins#options