2022.2

Table Of Contents
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"onpage250),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).
ThebigadvantageofusingHandlebarssnippetsinOLConnectisthatonlyoneortwoverysimple
Designerscriptsareneededtoreplaceapotentiallylargenumberofexpressionswithvaluesandinsert
thecontentinasection.ThisisespeciallybeneficialforOLConnecttemplateswithmanysnippetsand
variabledatathatwouldotherwiserequirealargenumberofscripts.
WorkingwithHandlebarstemplatesinvolvesalittlebitofscripting.Ifyouarenewtoscriptinginthe
Designer,firstread:"Writingyourownscripts"onpage368.
Note: TheinformationinthisOnlineHelpfocusesontheimplementationofHandlebarsinOL
Connect.ForgeneralinformationaboutHandlebarsandhowtouseit,seethefollowingweb
sites:https://handlebarsjs.com/andhttps://devdocs.io/handlebars.
Page 339