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>Written by Erick
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Java
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#