Add generic Map implementation (#108) Instead of waiting for a good time to switch the `Map` implementation, I've decided to just offer two implementations: one for Go versions before 1.18, and one for 1.18 and onwards. This is achieved using build tags in the source files. This is obviously a breaking change for consumers of this library that use Go 1.18 and onwards. See #88
1 file changed, 5 insertions(+), 2 deletions(-)
changed files
M examples/tailwindcss/tailwindcss.go → examples/tailwindcss/tailwindcss.go
@@ -1,3 +1,6 @@ +//go:build go1.18 +// +build go1.18 + package main import (@@ -81,8 +84,8 @@ Div(Class("flex items-center space-x-4 h-16"), NavbarLink("/", "Home", currentPath == "/"), // We can Map custom slices to Nodes - g.Group(g.Map(len(links), func(i int) g.Node { - return NavbarLink(links[i].Path, links[i].Name, currentPath == links[i].Path) + g.Group(g.Map(links, func(pl PageLink) g.Node { + return NavbarLink(pl.Path, pl.Name, currentPath == pl.Path) })), ), ),