Use gomponent's MapMap function
1 file changed, 1 insertion(+), 11 deletions(-)
jump to
M templates/layout.go → templates/layout.go
@@ -22,16 +22,6 @@ TitleAttrs Attrs BodyAttrs Attrs } -// Map a map of anything to a [Group] (which is just a slice of [Node]-s). -func MapMap[K comparable, T any](ts map[K]T, cb func(K, T) g.Node) g.Group { - nodes := make([]g.Node, 0, len(ts)) - for k, t := range ts { - nodes = append(nodes, cb(k, t)) - } - - return nodes -} - func extendAttrs(base Attrs, attrs Attrs) g.Node { m := base for key, value := range attrs {@@ -42,7 +32,7 @@ m[key] = value } } - return MapMap(m, func(k string, v string) g.Node { + return g.MapMap(m, func(k string, v string) g.Node { return g.Attr(k, v) // can't inline this because it uses ...value, grr }) }