H creates a VDomElem with the specified tag, properties, and children. This is the primary function for creating virtual DOM elements. Children can be strings, VDomElems, *VDomElem, slices, booleans, numeric types, or other types which are converted to strings using fmt.Sprint. nil children are allo
(tag string, props map[string]any, children ...any)
| 89 | // or other types which are converted to strings using fmt.Sprint. |
| 90 | // nil children are allowed and removed from the final list. |
| 91 | func H(tag string, props map[string]any, children ...any) *VDomElem { |
| 92 | rtn := &VDomElem{Tag: tag, Props: props} |
| 93 | if len(children) > 0 { |
| 94 | for _, part := range children { |
| 95 | elems := ToElems(part) |
| 96 | rtn.Children = append(rtn.Children, elems...) |
| 97 | } |
| 98 | } |
| 99 | return rtn |
| 100 | } |
| 101 | |
| 102 | // If returns the provided part if the condition is true, otherwise returns nil. |
| 103 | // This is useful for conditional rendering in VDOM children lists, props, and style attributes. |