2022.1

Table Of Contents
l the name of a Handlebars template (.hbs) in the template
l the name of a Handlebars template (.hbs) on disk (file:///)
l the name of a remote Handlebars template (.hbs) (http:// or https://)
l a string that contains HTML and Handlebars expressions.
With a snippet on disk, the complete syntax is:file://<host>/<path>. If the host is"localhost", it
can be omitted, resulting infile:///<path> - note the three forward slashes after file:.
In the remainder of the path you can either use escaped backward slashes:
"file:///C:\\Users\\Administrator\\Desktop\\Handlebars_LoadFile.hbs"
or forward slashes:
"file:///C:/Users/Administrator/Desktop/Handlebars_LoadFile.hbs"
The data can be the current record or part of it, or a JavaScript object.
If no data is passed, the current record will be used.
Add the HTML to a section
Finally, the rendered HTML can be added to the content of a section.
For example: results.replaceWith( html )
Alternative: compile and call the template
The render() function actually does two things:
1. Compile the Handlebars template into a function
Handlebars templates need to be compiled first. When a Handlebars template is
compiled, it is actually compiled into a JavaScript function.
2. Call the function to replace expressions with data
The second step is to call the resulting function, passing in some data. The function will
replace the expressions with values from the data and will then return HTML.
Instead of calling Handlebars.render() you could call Handlebars.compile() and then call the
resulting function. For example:
var myFunction = Handlebars.compile( "snippets/policy-info.hbs",
record);
let html = myFunction( record )
Handlebars sample code from an online source will use the two separate steps since
Handlebars.render() is only available in Connect.
Page 289