ds

package
v0.0.0-...-228a784 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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

func ActionClipboard(data string) string

Copies the provided evaluated expression to the clipboard.

func ActionSetAll

func ActionSetAll(paths string, value string) string

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

func ActionToggle(paths string) string

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 Delete

func Delete(url string, opts ...Options) string

Works the same as Get but sends a DELETE request to the backend.

func Get

func Get(url string, opts ...Options) string

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 Join

func Join(parts ...string) string

Join joins scripts/actions with "&&"

func OnEnterKey

func OnEnterKey(actions ...string) string

OnEnterKey applies FilterEnterKey to a set of actions.

func Patch

func Patch(url string, opts ...Options) string

Works the same as Get but sends a PATCH request to the backend.

func Post

func Post(url string, opts ...Options) string

Works the same as Get but sends a POST request to the backend.

func Put

func Put(url string, opts ...Options) string

Works the same as Get but sends a PUT request to the backend.

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

Jump to

Keyboard shortcuts

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