The following helpers are available both client and server-side in the various fields that use the Handlebars templates, and in email and PDF generation.
These helpers are based upon the Swag Handlebars Helpers released under the MIT license and available here www.npmjs.com/package/swag Their documentation has been updated and reproduced below.
For anyone not familiar with the examples, they are characters from Futurama (opens new window)
Use in Forms
These helpers can be used in all of the form field types that include the Handlebars editor.
Data may be supplied to your template by the field's default function, updated using the manipulation function, or, in the case of the Ajax Template, be requested from an End Point or other API Server worker available browser-side.
JSON Data
JSON data is often supplied in a result object or array, so you'll often use result in your template.
For example, if your data is supplied as:
{
"jsonrpc": "2.0",
"id": 42,
"result": {
"result": [{
"name": "Leela",
"deliveries": 8021
}, {
"name": "Bender",
"deliveries": 239
}, {
"name": "Fry",
"deliveries": 1
}]
}
}
You could use the HTML "ul" helper, and Inflections "inflect" helper, to create a template like:
{{#ul result class="deliveries-list"}}
{{name}} - {{inflect deliveries "delivery" "deliveries" true}}
{{/ul}}
Which would output:
- Leela - 8021 deliveries
- Bender - 239 deliveries
- Fry - 1 delivery