Documentation ¶
Overview ¶
Package helpers provides utility functions and types to simplify and enhance the creation and manipulation of godom elements and attributes.
Index ¶
- func FlagAttribute(flag string) types.Attribute
- func MultiValueAttribute(key string, values ...string) types.Attribute
- func NewChildlessElement(tag string, attrs ...types.Attribute) types.Element
- func NewElement(tag string, attrs ...types.Attribute) types.ElementFactory
- func NewStringElement(content string) types.Element
- func SingleAttribute(key, value string) types.Attribute
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FlagAttribute ¶
FlagAttribute creates an attribute that acts as a flag (i.e., key without a value). Example usage for boolean attributes: FlagAttribute("disabled")
func MultiValueAttribute ¶
MultiValueAttribute creates an attribute with a key that can hold multiple space-separated values. If the attribute already exists, the new values are appended. Example usage for a class attribute: MultiValueAttribute("class", "btn", "btn-primary")
func NewChildlessElement ¶
NewChildlessElement creates a new types.Element that cannot have child elements. It initializes the element with the provided tag and any additional attributes. Example usage: NewChildlessElement("br", someAttribute)
func NewElement ¶
func NewElement(tag string, attrs ...types.Attribute) types.ElementFactory
NewElement creates a factory function for a new types.Element with the given tag and attributes. The factory function, when called, will produce an element with the specified child elements. Example usage: Div := NewElement("div"); divElement := Div(child1, child2)
func NewStringElement ¶
NewStringElement creates a new element that holds a static string as its content.
func SingleAttribute ¶
SingleAttribute creates an attribute with a single key-value pair. If the attribute with the same key already exists with a different value, it panics.
Types ¶
This section is empty.