What is Handlebars?
Handlebars is a simple templating language.
A template is an HTML document that contains embedded Handlebars expressions.
Data is passed into the template to generate the final HTML. This process is called "Applying data to a template". It transforms the data into an HTML document.
The original implementation of Handlebars is in JavaScript. Data will be passed as a JavaScript object. In priint cloud we use a Java implementation of Handlebars instead. Data will be passed as Java objects that have been deserialized from JSON.
Templates look like regular text with embedded Handlebars expressions.
Example Template:
Expressions are enclosed in double curly braces. With expressions, you can:
- output values from the data source
- execute a helper function to do all fancy stuff
Example Helpers:
In priint cloud we provide all basic helpers from the original Handlebars.js. In addition to this, we provide a comprehensive library of additional helpers, all implemented in Java. And in edge cases you can also implement our own custom helpers in JavaScript.
Links
- Handlebars.js documentation (https://handlebarsjs.com/)
- Documentation of the Java port (https://jknack.github.io/handlebars.java/)