2022.1

Table Of Contents
Using logic in a Handlebars template: helpers
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.
Block helpers
Functions that can be called from a Handlebars expression are called helpers. Handlebars
offers a number of built-in block helpers that let you use logic in templates. Block helpers look
like this: {{#helperName arguments}}...{{/helperName}}.
They are documented on Handlebars' website: https://handlebarsjs.com/guide/builtin-
helpers.html.
Of those helpers, the following are supported in OLConnect:
l #if: Conditionally renders a block. An optional {{else}} section inside the block will display
when the condition is not true.
l #unless: Renders a block if the expression returns a falsy value (i.e. a value that is
considered false when encountered in a Boolean context). An optional {{else}} section
inside the block will display when the condition is true.
l #each: Allows to iterate over a list. An optional {{else}} section inside the block will
display when the list is empty.
l #with: Can be used to work directly with the passed object or object property. An optional
{{else}} section will display only when the passed value is empty.
In block helpers, the data variables @first, @last, @index can be used; see
https://handlebarsjs.com/api-reference/data-variables.html.
Unlike in the original Handlebars library, content provided by a block helper is not
automatically HTML-escaped in OL Connect. Blocks are typically used to generate HTML, so
it is assumed that the result consists of well-formed HTML.
Page 982