gotmpl4j
A pure-Java implementation of Go’s text/template engine,
with the Sprig function library and an optional Spring
Boot starter. No Go toolchain, no CGo, no native bindings — just the JVM.
It renders the same templates Helm, Hugo, and countless Go CLIs use, and is validated for
byte-for-byte parity against Go’s own text/template test suite and Sprig’s upstream tests.
1. Highlights
-
The full Go
text/templateengine — lexer, parser, AST, executor — and Go’s 19 built-in functions. -
The Sprig function library: strings, lists, dicts, math, crypto, date, semver, encoding, and more.
-
Contextual HTML auto-escaping ported from Go’s
html/template(opt-in). -
A Spring Boot starter: a ready-to-inject engine, configuration properties, a compile cache, and an MVC/WebFlux
ViewResolver. -
Pluggable functions via
ServiceLoader— drop a module on the classpath and its functions appear.
2. Modules
| Artifact | Description |
|---|---|
|
The engine: lexer -> parser -> AST -> executor. Go builtins only; functions are pluggable via |
|
The Sprig function library, auto-discovered when on the classpath. |
|
Spring Boot auto-configuration: engine bean, configuration properties, compile cache, function beans, and an optional |
gotmpl4j-core has zero dependency on Sprig or any host application. Add gotmpl4j-sprig
for the Sprig functions, or the starter for Spring Boot integration.
3. Next
-
Getting started — add the dependency and render your first template.
-
Template syntax — actions, pipelines, control flow, and the Go built-ins.
-
Sprig functions — the function catalog.
-
Spring Boot starter — auto-configuration and the view resolver.
-
Conformance — how correctness is held to the Go and Sprig originals.