2022.2

Table Of Contents
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"onpage808.
Note: TheinformationinthisOnlineHelpfocusesontheimplementationofHandlebarsinOL
Connect.ForgeneralinformationaboutHandlebarsandhowtouseit,seethefollowingweb
sites:https://handlebarsjs.com/andhttps://devdocs.io/handlebars.
CreatingaHandlebarstemplate
Tocreateanew,emptyHandlebarstemplate:
1. OntheResourcespane,right-clicktheSnippetsfolderandselectNew Snippet.
2. Selectthetypeofsnippetthatyouwanttocreate:Handlebars template.
3. Givethesnippetaname.
4. Double-clickthenewfiletoopenitintheDesignerandfillitwithHTMLtextandHandlebars
expressions.
TheeditorforHandlebarssnippetsdoesnothaveaDesignview.HTMLwithHandlebarsexpressionsis
notnecessarilyvalidHTML.ProcessingitwithanHTMLparsermightbreakboththeHandlebars
expressionsandtheHTML.
Moreaboutexpressionsandthefunctionsthatyoucanuseinexpressionscanbefoundinthetopics
"Handlebarsexpressions"onpage763and"Usingfunctionsinexpressions:Helpers"onpage766.
UsingaHandlebarstemplateinasection
AlthoughHandlebarstemplatescontainHTMLtext,theycannotbeinsertedintothecontentofasec-
tionastheyare.Theexpressionswouldnotbereplacedwithdata.
WhatittakesisashortscriptthatreplacestheHandlebarsexpressionswithvaluesandthenaddsthe
contentoftheHandlebarstemplatetoasection.
1. OntheScriptspane,clickontheblacktrianglenexttotheNewbuttonandselectStandard
Script.
2. Givethescriptaname.
3. Entertheselectorthatwillidentifyelementsinthetemplateforwhichthescriptshouldrun.(See:
"SelectorsinOLConnect"onpage825.)
Page 775