Home
GoHT, pronounced like “Goat”, is a Haml, Slim, and EGO template engine and file generation tool for Go.
It reads .goht files and generates type-safe Go code that renders HTML without runtime template parsing.
GoHT lets you write templates alongside normal Go code.
Use @haml, @slim, or @ego blocks in a .goht file, then run the generator to produce HTML-rendering Go functions.
Features
- Haml Syntax - Use compact Haml-style tags, attributes, interpolation, filters, and nesting.
- Slim Syntax - Use terse Slim-style templates with bare tag names and indentation.
- EGO Syntax - Use HTML-oriented templates with Go tags such as
<%= value %>. - Type-Safe Generated Go - Compile templates to Go functions checked by the compiler.
- Multiple Templates Per File - Keep related Haml, Slim, and EGO templates together.
- Mixed Go and Templates - Put normal Go declarations alongside template blocks.
- Easy Nesting - Render templates inside other templates with
@renderand@children. - Named Slots - Compose reusable layouts with named content regions.
- IDE Support - VS Code, JetBrains IDEs, TextMate syntax support, and LSP integration.
Quick Start
Install the CLI.
Add the library to your module.
Write This
Write a template into a .goht file.
You can also keep different template syntaxes in the same .goht file.
Compile the template into Go code.
Run This
After the generation step, you can call the generated Go function. Generated template functions return goht.Template, and Render(ctx, writer) writes to any io.Writer, including http.ResponseWriter.
To see this:
Prefer @haml for Haml templates. The older @goht directive is still accepted for backward compatibility, but it is deprecated.
