Build custom templates with Handlebars

DynamoPDF uses the power of handlebars to enable custom PDF generation.

Checkout the official Handlebars docs site at handlebarsjs.com and try live demo.

What is Handlebars?

Handlebars is a simple templating language.

It uses a template and an input object to generate HTML or other text formats. Handlebars templates look like regular text with embedded Handlebars expressions.

<p>{{firstname}} {{lastname}}</p>

A handlebars expression is a {{, some contents, followed by a }}. When the template is executed, these expressions are replaced with values from an input object.

If applied to the input object

{
  firstname: "Yehuda",
  lastname: "Katz",
}

the expressions will be replaced by the corresponding properties. The result is then

<p>Yehuda Katz</p>