Documentation
¶
Overview ¶
Package util provides utility functions for godom package, enhancing the flexibility and ease of use in creating and manipulating the DOM.
Index ¶
- func DelayedAttribute(attribute types.Attribute) types.Attribute
- func DelayedElement(creator ElementCreator) types.Element
- func IfAttr(condition bool, attribute types.Attribute) types.Attribute
- func IfElem(condition bool, element types.Element) types.Element
- func Map[T any](data []T, creator func(T) types.Element) types.Element
- func RenderToString(element types.Element) (string, error)
- type ElementCreator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DelayedAttribute ¶
DelayedAttribute wraps the provided types.Attribute such that it renders every time the containing types.Element is rendered. This allows attributes to be dynamically determined during the rendering phase.
func DelayedElement ¶
func DelayedElement(creator ElementCreator) types.Element
DelayedElement returns a godom.Element that is constructed immediately before rendering. This allows for dynamic adaptation of parts of the DOM between its construction and rendering phases.
func IfAttr ¶
IfAttr returns a godom.Attribute that is applied to the godom.Element based on the given condition. If the condition is true, the provided attribute is applied; otherwise, a no-op attribute is applied.
func IfElem ¶
IfElem returns a godom.Element based on the given condition. If the condition is true, the provided element is returned; otherwise, an empty element is returned.
Types ¶
type ElementCreator ¶
ElementCreator defines a function type that creates and returns a godom.Element.