Te4j
About the project
Te4j (Template Engine For Java) - Fastest and easy template engine
Pros
- Extremely fast (
127k
renders per second on 4790K) - Easy and simple syntax
- No dependencies
temporary
)
Cons (- No community :(
- Sometimes really bad code
- No javadocs
- Poor documentation
Benchmarks
Example
<p>Message: ^^ message ^^p>
class Pojo {
String getMessage() {
return "Hello world!";
}
}
Pojo pojo = new Pojo();
Template<Pojo> template = Te4j.load(Pojo.class, "index.html");
String result = template.renderAsString(pojo);
// result = Message: Hello world!
Also, you are able to create custom template context
TemplateContext ctx = Te4j.custom()
// deletes repeating spaces, tabs, cr and lf from output
.replace(Te4j.DEL_ALL)
// you can choose which output type will be used
//
// if you want to choose multiple output types,
// you can use | operator
//
// BYTES - renderAsBytes and renderTo will be optimized
// STRING - renderAsString will be optimized
.outputTypes(Te4j.BYTES | Te4j.STRING)
// btw you can enable hot reloading
//
// it does not impact performance,
// but I recommend disabling it in production
// for max. performance
.enableHotReloading()
.build();
Template<Pojo> template = ctx.load(Pojo.class, "index.html");
More examples in docs
Full Docs
Add as dependency
Maven
<dependencies>
<dependency>
<groupId>com.github.lero4ka16groupId>
<artifactId>te4jartifactId>
<version>1.1.1version>
dependency>
dependencies>
Gradle
dependencies {
implementation 'com.github.lero4ka16:te4j:1.1.1'
}
Build the project
- Execute
./gradlew build
- Output file located at
build/libs/te4j.jar
Contact
Post Scriptum
I will be very glad if someone can help me with development.