jte

A fast and lightweight
template engine for Java

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>1.4.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 1606432038020.

Congratulations! You got jte up and running 🤘.

📚 Further reading