Logic-less and semantic templates with Java

by Edgar Espina Theme by mattgraham

{{ Mustache }} templates in Java

Handlebars.java is a Java implementation of Mustache. You can use Handlebars.java in any Java environment, but especially in web applications that make heavy use of JavaScript.

So, what make Handlebars.java special for web development?

Beside Handlebars.java is a multi-purpose template engine, one of the reason that makes Handlebars.java special, is that you can use the same template engine in the browser.

These are the most used implementations of Mustache for JavaScript

Of course that Handlebars.js is what makes more sense to use, but you can also choose between any other existing implementations of Mustache.

Getting Mustache

The best way of getting started is by reading the Mustache documentation. You will find it very easy to follow and understand.

Then you might want to read the Handlebars.js documentation for a better understanding of how Handlebars.js extends Mustache through the use of helpers.

Hello Handlebars.java!

Handlebars handlebars = new Handlebars();
Template template = handlebars.compileInline("Hello {{this}}!");

Print out:

Hello Handlebars.java!

Mustache is very simply template engine with just a few constructions. In the example above, "{{this}}" get resolved to "Handlebars.java".

Built-in helpers:

Want to contribute?

Thank you, for reading the Handlebars.java blog.