2022.2

Table Of Contents
Toregisterapartial,usethefollowingfunctioninascript:Handlebars.registerPartial('partialName',
'template')(fordetailssee:"HandlebarsAPI"onpage344).
Forexample,thislineofcoderegistersatemplate(clauses.hbs)asapartialwiththename'clauses':
Handlebars.registerPartial('clauses', 'snippets/partials/clauses.hbs');
Tip: PartialsregisteredinaControlScriptwillbeavailableinallstandardscripts.ControlScripts
areexecutedfirst.(See"ControlScripts"onpage398.)
Note: RegisteringmultiplepartialswithasinglecallisnotsupportedinOLConnect.
UsingpartialsinHandlebarstemplates
ToincludeapartialinaHandlebarstemplate,insertanexpressionthatreferstoit,forexample:
{{> partialname.hbs}}.
Relativepaths(startingwithsnippets/)andarbitraryURLs(startingwithfile://orhttp://orhttps://)are
supported.
Thefilenamecanbe:
l
thenameofan.hbssnippetinthetemplate(forexample:{{> snippets/Snippet 1.hbs}}
l
thenameofan.hbssnippetondisk(startingwithfile:///)
l
thenameofaremote.hbssnippet(startingwithhttp://orhttps://)
Withasnippetondisk,thecompletesyntaxis:file://<host>/<path>.Ifthehostis"localhost",itcanbe
omitted,resultinginfile:///<path>-notethethreeforwardslashesafterfile:.
Intheremainderofthepathyoucaneitheruseescapedbackwardslashes:
"file:///C:\\Users\\Administrator\\Desktop\\Handlebars_LoadFile.hbs"
orforwardslashes:
"file:///C:/Users/Administrator/Desktop/Handlebars_LoadFile.hbs"
Note: Apartialiscompiledautomaticallywhenthetemplateinwhichitisinsertedisrendered.
Using a registered partial in a template
Registeredpartials(see"Howtoregisterapartial"onthepreviouspage)canbereferredtobyname
insteadoffilename,usingthefollowingsyntax:
{{> partialName}}.
Forexample,apartialthatisregisteredasfollows:
Handlebars.registerPartial('clauses', 'snippets/partials/clauses.hbs');
canbeincludedinaHandlebarstemplatewiththefollowingexpression:{{>clauses}}.
Page 259