Version 0.23.0
🚀 New Features
Merge
Added to attrs
Subpackage
The Merge
method allows for the merging of multiple attrs.Props
maps into a single attrs.Props
map. This is particularly useful when you need to apply a base set of attributes and then selectively override or add additional attributes under certain conditions. The method accepts a variadic input, enabling the easy combination of any number of attrs.Props
maps. Attributes from later arguments will override those from earlier ones if there are any key conflicts.
Usage
defaultButtonAttrs := attrs.Props{
attrs.Class: "btn",
attrs.Type: "button",
}
userButtonAttrs := attrs.Props{
attrs.Class: "btn btn-primary",
attrs.ID: "submitBtn",
}
mergedButtonAttrs := attrs.Merge(defaultButtonAttrs, userButtonAttrs)
button := elem.Button(mergedButtonAttrs, elem.Text("Submit"))