2022.2

Table Of Contents
Note: TheinformationinthisOnlineHelpfocusesontheimplementationofHandlebarsinOL
Connect.ForgeneralinformationaboutHandlebarsandhowtouseit,seethefollowingweb
sites:https://handlebarsjs.com/andhttps://devdocs.io/handlebars.
Functions
compile('template') CompilesthespecifiedHandlebarstemplate*intoafunctionthatcanbecalledwithdata**.Forexample:
const template = Handlebars.compile('snippets/Template1.hbs');
const result = template(record);
Note: PassingoptionsisnotsupportedinOLConnect.
render('template',data) RendersaspecifiedHandlebarstemplate*bycompilingthespecifiedHandlebarstemplateintoafunctionandimme-
diatelycallingthatfunctionwithdata**.
Handlebars.render( "snippets/Template.hbs" )
isidenticalto:
const compiledTemplate = Handlebars.compile( "snippets/Template.hbs" )
compiledTemplate( record )
Ifdataispassed,thatdataisusedtorenderthetemplate.
Ifnodataispassed,thecurrentrecordisusedtorenderthetemplate.
TheresultofthisfunctionisHTML.
Seealso:"Handlebarstemplates"onpage339.
registerPartial('name',
'template')
RegistersaHandlebarstemplate*asapartialwiththespecifiedname.
Forexample,thislineofcoderegistersatemplate(clauses.hbs)asapartialwiththename'clauses':
Handlebars.registerPartial('clauses', 'snippets/partials/clauses.hbs');
ThepartialcanthenbereferredtobyitsnameinHandlebarstemplatesaswellasfunctionsusing{{> partialName}}.For
example:{{> clauses}}.
See:"Partials"onpage342.
registerHelper('name',
helper)
RegistersafunctionasHelperwiththespecifiedname.
Hereisanexample:
Handlebars.registerHelper('today', function() { return new Date(); });
See:"CreatingcustomHelpers"onpage336.
Note: RegisteringmultipleHelperswithasinglecalltoregisterHelper()isnotsupported.
escapeExpression() HTML-escapesthesuppliedstring.ThismeansthatthosecharactersthathaveaspecialfunctioninHTML:& < > \" ' ` =
arereplacedwithHTMLcharacterreferences.Forexample:&willbechangedinto&amp;.
Seealso:"HTMLvalues"onpage329.
ThisfunctiondoesthesameasescapeHTML(),whichwasintroducedinOLConnect2022.1andisnowdeprecated.
Page 345