Why jte?
- Compile time checked and context-sensitive
- IntelliJ plugin offering completion and refactoring support
- Hot reloading of templates during development
- Intuitive, easy to learn syntax
- Blazing fast execution (~100k renders/s on a MacBook Pro 2015)
- Very small footprint (just one external dependency for HTML escaping)
🚀 Getting started
Create a new file src/main/jte/hello.jte:
@param String name Hello ${name}! The current timestamp is ${System.currentTimeMillis()}.
Add maven dependency
<dependency> <groupId>gg.jte</groupId> <artifactId>jte</artifactId> <version>1.9.0</version> </dependency>
Render the template:
// Tell jte where your template files are located var codeResolver = new DirectoryCodeResolver(Path.of("src", "main", "jte")); // Create the template engine (usually once per application) var templateEngine = TemplateEngine.create(codeResolver, ContentType.Html); // Render var output = new StringOutput(); templateEngine.render("hello.jte", "World", output); System.out.println(output);
Run the program and you should see this console output:
Hello World! The current timestamp is 1618955632401.
Congratulations! You got jte up and running 🤘.