Why jte?
- Intuitive, easy to learn syntax
- Write plain Java or Kotlin for expressions
- Context-sensitive output escaping at compile time
- IntelliJ plugin with completion and refactoring support
- Hot reloading of templates during development
- Blazing fast execution (~100k renders/s on a MacBook Pro 2015)
🚀 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>2.2.4</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 1686185478396.
Congratulations! You got jte up and running 🤘.