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.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of pure Go

pure Go

Photo of html components

html components

Photo of gomponents

gomponents

Related news:

News photo

CSS written in pure Go

News photo

A MySQL compatible database engine written in pure Go