GoHT GoHT

GoHT, pronounced like “Goat” is a Go-based implementation of the Haml templating language. It is a code generator that takes Haml templates and generates Go code.

GoHT allows you to write your Haml template alongside your Go code. A code generation step is then used to compile the Haml into HTML-producing Go code.

Features

  • Haml Syntax - GoHT uses the Haml syntax for writing templates.
  • Go Integration - GoHT templates are Go code and can be used in any Go application.
  • Easy Nesting - Easily nest other GoHT templates inside other GoHT templates.
  • Type Safety - Templates are compiled to type-safe Go and not parsed at runtime.
  • IDE Support - JetBrains IDEs and VS Code, with more to come.

Write This

Write some Haml into a .goht file.

@goht HelloWorld(name string) {
%p Hello, #{name}!
}

Compile the Haml into Go code.

$ goht generate

Run This

After the generation step, you can call the generated Go function to produce HTML.

func main() {
	HelloWorld("World").Render(context.Background(), os.Stdout)
}

To see this:

<p>Hello, World!</p>