2022.2

Table Of Contents
}
]
ThefollowingcoderegistersaHelpercalledmakeHyperlinkthatwillturnthesevaluesintoahyperlink
inthetext.
Handlebars.registerHelper('makeHyperlink', function () {
let result = `<a href="${this.url}">${this.label}</a>`;
return new Handlebars.SafeString( result );
})
Inthetemplateyouwouldcallthefunctioninanexpression.
Example: Goto{{makeHyperlink}}
HTML-escapinginaHelper
IfaHelperneedstoHTML-escapeastringyoucancallHandlebars.escapeExpression()inthatfunc-
tion.
Forexample,ifyouwouldwanttoHTML-escapethevalueofthis.field,butnot"<p>"or"</p>",you
couldwrite:
function() { return "<p>" + Handlebars.escapeExpression(this.field) +
"</p>"; }
Note: Asaruleofthumb,putasmuchcontentinthetemplateaspossibleandletHelpersgen-
erateaslittlecontentaspossible.
Handlebars templates
InOLConnect,Handlebarstemplatesareaspecialkindofsnippets.Justlikeothertypesofsnippets
(see"Snippets"onpage661),HandlebarstemplatesarestoredintheSnippetsfolderonthe
Resourcespane,buttheirfilenameendsin.hbs.
HandlebarsisthenameofaJavaScriptlibrarythatimplementsatemplatinglanguage(see
https://handlebarsjs.com/).Itusesatemplateandaninputobjecttogenerateoutput.
ThetemplatelookslikeregulartextwithembeddedHandlebarsexpressions.Ahandlebarsexpression
issomecontentsenclosedbydoublecurlybraces:{{...}}.Forexample:
<p>Hello {{firstname}}!</p>
Whenthetemplateisrendered,theseexpressionsarereplacedwithvaluesfromaninputobject.
TheHandlebarslibraryisintegratedinOLConnectDesigner.ThismeansthatyoucanuseHandle-
barsexpressionsinallsections(asofversion2022.2),aswellasinaspecialtypeofsnippetscalled
"Handlebarstemplates"(asofversion2022.1).
Page 774