Handlebars in OL Connect

Handlebars is the name of a JavaScript library that implements a templating language (see https://handlebarsjs.com/). It uses a template and an input object to generate output.

The template looks like regular text with embedded Handlebars expressions. A handlebars expression is some contents enclosed by double curly braces: {{ ... }}. For example:
<p>Hello {{firstname}}!</p>

When the template is rendered, these expressions are replaced with values from an input object.

The Handlebars library is integrated in OL Connect Designer. This means that:

  • Handlebars expressions can be used in all sections as of version 2022.2.

    Note: In templates made with OL Connect 2022.1 or older, Handlebars expressions are not evaluated by default. To enable expressions in a section, right-click the section in the Resources pane, select Properties and check the option Evaluate Handlebars expressions.

  • Handlebars expressions can be used in a special type of snippets called "Handlebars templates". These were introduced in version 2022.1. See Handlebars templates.

Expressions are inserted in sections and Handlebars templates the same way; see Variable data in text: expressions.

HTML mixed with Handlebars expressions is not necessarily valid HTML. Processing it with an HTML parser - like the editor in which sections are written - might break both the Handlebars expressions and the HTML. This happens, for example, when #each (a Handlebars Helper) is used to create table rows.
Consider creating a Handlebars snippet whenever you find yourself switching to Source view to insert expressions and HTML. The Handlebars template editor is a plain text editor, not an HTML parser.

More about expressions and the functions that you can use in expressions can be found in the topics Handlebars expressions and Using functions in expressions: Helpers.

Handlebars templates can in turn use other Handlebars templates as snippets. They are called partials. How this works is explained in the topic: Partials.

Note: The information in this Online Help focuses on the implementation of Handlebars in OL Connect. For general information about Handlebars and how to use it, see the following web sites: https://handlebarsjs.com/ and https://devdocs.io/handlebars.