Get the latest tech news
Show HN: Gomponents, HTML components in pure Go
HTML components in pure Go, that render to HTML 5.
"maragu.dev/gomponents/html" ) type NavLink struct { Name string Path string } func Navbar(loggedIn bool, links []NavLink) Node { return Nav(Class("navbar"), Ol( Map(links, func(l NavLink) Node { return NavbarItem(l.Name, l.Path) }), If(loggedIn, NavbarItem("Log out", "/logout"), ), ), ) } func NavbarItem(name, path string) Node { return Li(A(Href(path), Text(name))) } gomponents are HTML components in pure Go. Contact me at markus@maragu.dk to discuss options for a one-time or recurring invoice to ensure its continued thriving. PS: There's also Iff, which takes a callback function instead, to avoid those pesky nil pointer errors.
Or read this on Hacker News