Last Updated: February 25, 2016
·
1.072K
· erickzanardo

doT.js templates in Java

When you need to reuse doT.js templates in your java application/server you can use a lib I've created: https://github.com/erickzanardo/dj.

It's very simple to use. Check the following code:

// JsonObject is a class from GSON lib
JsonObject object = new JsonObject();
object.addProperty("foo", "with doT");

String result = new DJ()
               .template("<h1>Here is a sample template {{=it.foo}}</h1>")
               .context(object).result();
// <h1>Here is a sample template with doT</h1>