2022.2

Table Of Contents
}
results.replaceWith( html );
Selecting a Handlebars template based on a data field
AnapproachthatisalsousedwithHTMLsnippetsistousethevalueofadatafieldinthecurrent
recordtodeterminethenameoftheHandlebarstemplatetouse.
Thisisanexample:
let html = ''
let policydata = record.tables.Policy
for (var i=0; i < policydata.length; i++) {
let templateName = 'snippets/' + policydata[i].fields['snippetName'] + '.hbs'
html += Handlebars.render( templateName, policydata[i] )
}
results.replaceWith( html );
Partials
PartialsarenormalHandlebarstemplatesthatmaybecalleddirectlybyothertemplates.Thistopic
explainshowtoworkwithHandlebarspartialsinOLConnect.
InformationaboutHandlebarstemplates(snippets)inOLConnectcanbefoundinthetopics"Handle-
barstemplates"onpage339.
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partial
AnyHandlebarstemplate,includingremoteHandlebarstemplates,canbeusedasapartialinaHandle-
barstemplate(snippet)inOLConnect.
TocreateapartialinanOLConnecttemplate,simplycreateanewHandlebarstemplate;see"Creating
aHandlebarstemplate"onpage340.
Tip: TokeepanoverviewyoucouldgroupthepartialsinasubfolderoftheSnippetsfolderon
theResourcespane.
Howtoregisterapartial
Itisnotmandatorytoregisterapartial,butitcanbeuseful,forexampleifyouwanttoworkwith
dynamicpartials.RegisteredpartialscanbereferredtoinHandlebarsexpressionsandfunctionsbythe
specifiedname;see"Usingaregisteredpartialinatemplate"onthenextpage.
Page 258