element

package
v0.129.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HXOption added in v0.100.0

type HXOption func(*Properties)

HXOption is a functional option to set a HTMX attribute.

func WithHXMethod added in v0.100.0

func WithHXMethod(method, value string) HXOption

WithHXMethod sets a "hx-{get,post,put,delete}" attribute.

func WithHXParams added in v0.100.0

func WithHXParams(params string) HXOption

WithHXParams sets a "hx-params" attribute.

func WithHXPushURL added in v0.108.0

func WithHXPushURL(value bool) HXOption

WithHXPushURL sets a "hx-push-url" attribute.

func WithHXSwap added in v0.108.0

func WithHXSwap(swap string) HXOption

WithHXSwap sets a "hx-swap" attribute.

func WithHXTarget added in v0.100.0

func WithHXTarget(target string) HXOption

WithHXTarget sets a "hx-target" attribute.

func WithHXValues added in v0.100.0

func WithHXValues(values map[string]any) HXOption

WithHXValues sets a "hx-vals" attribute. Note that the given map is marshaled to JSON and any marshaling error will silently result in no attribute being set.

type Properties added in v0.98.0

type Properties struct {
	// contains filtered or unexported fields
}

Properties represents properties of an element, including its attributes and classes.

func NewProperties added in v0.98.0

func NewProperties(options ...PropertiesOption) *Properties

NewProperties creates a Properties object for an element with the given options.

func (*Properties) Attributes added in v0.98.0

func (p *Properties) Attributes() templ.Attributes

Attributes returns the attributes as a templ.Attributes.

func (*Properties) Classes added in v0.98.0

func (p *Properties) Classes() []string

Classes returns the classes as a []string.

func (*Properties) HasAttribute added in v0.98.0

func (p *Properties) HasAttribute(key string) bool

HasAttribute returns a boolean indicating whether there is an attribute with the given key.

func (*Properties) ID added in v0.98.0

func (p *Properties) ID() string

ID returns the value of the "id" attribute. If there is no id attribute, an empty string is returned.

func (*Properties) SetAttribute added in v0.98.0

func (p *Properties) SetAttribute(key string, value any)

SetAttribute sets an attribute with the given key to the given value. Any existing value is overridden.

type PropertiesOption added in v0.98.0

type PropertiesOption func(*Properties)

PropertiesOption is a functional option to set Properties.

func MergeAttributes added in v0.98.0

func MergeAttributes(attributes templ.Attributes) PropertiesOption

MergeAttributes option merges the given attributes with any existing attributes.

func WithAttribute

func WithAttribute(key string, value any) PropertiesOption

WithAttribute option sets a key-value attribute on the properties. Any existing value is overridden.

func WithClasses

func WithClasses(classes ...string) PropertiesOption

WithClasses option sets the classes on the properties. New values are merged with existing values and any duplicates removed.

func WithHXOptions added in v0.100.0

func WithHXOptions(options ...HXOption) PropertiesOption

WithHXOptions option is a way to set all HX options at once.

Jump to

Keyboard shortcuts

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