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
WithHXMethod sets a "hx-{get,post,put,delete}" attribute.
func WithHXParams ¶ added in v0.100.0
WithHXParams sets a "hx-params" attribute.
func WithHXPushURL ¶ added in v0.108.0
WithHXPushURL sets a "hx-push-url" attribute.
func WithHXSwap ¶ added in v0.108.0
WithHXSwap sets a "hx-swap" attribute.
func WithHXTarget ¶ added in v0.100.0
WithHXTarget sets a "hx-target" attribute.
func WithHXValues ¶ added in v0.100.0
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.