ADR-002 — HTML Templating Engine
ADR |
ADR-002 |
|---|---|
Title |
HTML Templating Engine |
State |
Accepted |
Author |
klenkes74 |
Decision Body |
klenkes74 |
Valid from |
2025-06-07 |
Expires |
./. |
1. Context
The {gloss_scs} produces HTML for the web application. The HTML is needed for the controlled pages and for the {gloss_transclude}s.
2. Decision
While there are very good reasons to use Thymeleaf or FreeMarker as templating engines, I decided to use JTE. It is an easy to use, modern templating engine that is specifically designed for Java applications. But more importantly: I want to get used to it, since it is used at my place of work.
3. Consequences
-
Templates have to be written in JTE syntax.
-
The templates are not HTML compliant, so they cannot be used as static HTML files.
4. Decision Drivers
| Driver | Description |
|---|---|
Strong support by spring-boot. |
|
Strong support for webflux and reactive programming. |
|
Mature and well-known. |
|
Easy to use and understand. |
|
Fulfilling JSR-223 Scripting Integration is not a requirement. |
5. Alternatives Considered
5.1. Thymeleaf
Thymeleaf is a modern server-side Java template engine for web and standalone environments with excellent Spring Boot integration.
Pro:
Con:
-
Slower than other engines with complex templates
-
Higher memory consumption
-
Steeper learning curve for advanced features (DD004 only partially fulfilled)
5.2. FreeMarker
FreeMarker is a powerful template engine with a focus on MVC patterns, distinguished by its speed and flexibility.
Pro:
Con:
-
No natural templates
-
Template syntax not HTML-compliant
-
Less deep Spring integration than Thymeleaf
5.3. Mustache
Mustache is a simple, logic-less template language implemented in many programming languages.
Pro:
-
Fulfills DD004 through extremely simple syntax
-
Minimal learning curve
-
Usable across languages
-
Strictly separates logic and presentation
Con:
5.4. Pebble
Pebble is a Java template engine inspired by Twig, with a focus on simplicity and performance.
Pro:
-
Good performance
-
Compact, easily understandable syntax (DD004)
-
Low memory consumption
-
Extensible
Con:
5.5. Handlebars
Handlebars extends Mustache with more functionality while maintaining its basic simplicity.
Pro:
-
Simple syntax (DD004)
-
Minimal logic possible in templates
-
Usable across languages
-
Extensible through helper functions
Con:
5.7. Jade4J/PUG
Java implementation of the Jade/Pug template language known from Node.js.
Pro:
-
Compact, indentation-based syntax
-
Fulfills DD004 through clean code
-
Popular in the JavaScript world
Con:
5.8. JTE (Java Template Engine)
JTE is a modern, lightweight template engine specifically for Java, designed for speed and type safety.
Pro:
-
Very high performance through pre-compilation of templates
-
Complete type safety during development
-
Good Spring Boot integration (DD001 fulfilled)
-
Supports WebFlux with reactive rendering (DD002 fulfilled)
-
Simple, intuitive syntax (DD004 fulfilled)
-
Hot-reloading during development
-
Low dependencies and minimal overhead
Con: