Package: hb
The HTML builder — a fluent, type-safe library for generating HTML in Go. Every UI surface
in the ecosystem (layouts, admin panels, form, bs, icons, liveflux) produces its markup
through hb.
Repository: https://github.com/dracory/hb
Installation
go get github.com/dracory/hb
Usage
package main
import (
"github.com/dracory/hb"
)
func main() {
tag := hb.Div().
Class("container").
Child(hb.H1().Text("Hello")).
Child(hb.Paragraph().Text("Built with hb."))
html := tag.ToHTML()
}
Features
- Builders for all standard HTML elements —
Div,Span,Input,Table, etc. - Attribute setters:
Attr,Class,ID,Style,Data,Hx*helpers. - Escaping built in — raw HTML only via explicit
Raw()APIs. - Custom components implement
TagInterfaceand compose with built-ins.