https://github.com/phillip-england/gtml
What is GTML?
GTML is a compiler which converts .html
files into composable .go
functions. Think of it like JSX for go.
Hello, World
Turn this:
<div _component="Greeting">
<h1>Hello, $prop("name")</h1>
</div>
Into this:
func Greeting(name string) string {
var builder strings.Builder
builder.WriteString(`<div _component="Greeting" _id="0"><h1>Hello, `)
builder.WriteString(name)
builder.WriteString(`!</h1>`)
return builder.String()
}
Installation
With go 1.22.3
or later, clone the repo and build the binary on your system.
git clone https://github.com/phillip-england/gtml;
cd gtml;
go build -o gtml main.go;
Then you’ll be left with a binary you can move onto your PATH.
mv gtml ./some/dir/on/your/path