gsx — JSX-style HTML templates

23 views
Skip to first unread message

Jackie Li

unread,
Jul 4, 2026, 11:59:35 AM (12 hours ago) Jul 4
to golang-nuts
I've been building gsx, a template compiler that lets you write type-safe HTML in Go with JSX-style markup. .gsx files hold ordinary Go plus component declarations; the generator lowers them to plain .x.go that go build type-checks. The runtime is standard-library only.

A quick taste:

component Card(title string, featured bool) {
    <section class={ "card", "card-featured": featured }>
    </section>
}

What it gives you:
- Props are generated structs, so wrong prop names/types are compile errors with real source locations (via //line directives), not runtime surprises.
- Context-aware escaping — text, attribute, URL, CSS, and JS positions each get the right treatment at codegen.
- Class/attribute merging, explicit JS-valued attributes, and automatic JSON interpolation for things like hx-vals.
- A gsx dev live-reload loop, an LSP, a tree-sitter grammar, and a VS Code extension.

Try it in the browser (no install): https://gsxhq.github.io/playground
Docs: https://gsxhq.github.io/ · Source (MIT): https://github.com/gsxhq/gsx

Thanks,
Jackie
Reply all
Reply to author
Forward
0 new messages