jte

Secure and speedy templates
for Java and Kotlin

jte in action

Why jte?

🚀 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 🤘.

📚 Further reading