|
For the latest stable version, please use gotmpl4j Spring Boot 4.1.1.1! |
gotmpl4j Spring Boot
Spring Boot integration for gotmpl4j — the
pure-Java implementation of Go’s text/template engine. Two artifacts:
| Artifact | What it gives you |
|---|---|
|
Auto-configuration: a ready-to-inject template engine, configuration properties, a compile cache, and optional MVC / WebFlux `ViewResolver`s so controllers can return view names. |
|
Template functions that read from the running application — |
1. Versioning — one branch per Spring Boot line
This project’s version tracks the Spring Boot release it builds against, in the form
<boot-version>.<revision>:
| Branch | Spring Boot | Example version |
|---|---|---|
|
4.1.x |
|
|
4.0.x |
|
Pick the artifact version matching your application’s Spring Boot line. main always tracks
the newest Spring Boot release; older lines get their own maintenance branch.
The engine itself (gotmpl4j-core, gotmpl4j-sprig) is Spring-free and versioned
separately on plain semver in the
gotmpl4j repository — one engine build serves every
Boot line.
|
2. Quick start
org.alexmond
gotmpl4j-spring-boot-starter
4.0.8.1
@Service
class GreetingService {
private final GoTemplateService templates;
GreetingService(GoTemplateService templates) {
this.templates = templates;
}
String greet(String name) {
return templates.render("greeting", Map.of("name", name));
}
}
Then configure the starter, add the Spring context functions, or browse the full property reference.
3. Template syntax and functions
Template syntax, the Sprig function library, and the extension SPI are documented with the engine:
-
Conformance — 1,305 cases asserted byte-for-byte against Go
4. API documentation
-
gotmpl4j-coreAPI (engine) -
gotmpl4j-sprigAPI (Sprig functions)