2022.2

Table Of Contents
ControlScriptsdon'ttouchthecontentofthesectionsthemselves,buttheycanchangethewayatem-
plateisoutputted.FormoreinformationaboutControlScriptsandtheiruse,see"ControlScripts"on
page838.
Tip: Doyoufindyourselfcopy-pastingthesamefunctionintoeverynewscript?Youcanavoid
thisbydefiningyourfunctioninaControlScript.ControlScriptsareexecutedfirst,sothefunction
willthenbeavailableinallStandardScriptsandPostPaginationScripts.
Handlebars Helpers
AHandlebarsHelper-afunctionthatcanbeusedinexpressions-isalsodefinedinaControlScript.
HelperscanbemadewiththeHandlebarsTextHelperwizard(see"UsingtheHelperWizard"on
page725)oryoucanwritethemyourself(see"CreatingcustomHelpers"onpage771).
StandardScripts
StandardScriptscanchangethecontentsofsectionsinatemplate.Thistypeofscriptmusthavea
selector.Theselectorcanbetext,anHTMLelementand/oraCSSselector(see"SelectorsinOLCon-
nect"onpage825).
RunningaStandardScriptstartswithlookingforpiecesofcontentinthetemplatethatmatchthe
script'sselector.
Theresultsofthisquerycanvaryfromoneoccurrenceofasimpletext(forexample:@EMAIL@)toa
largecollectionofHTMLelements.Forexample,whentheselectorisp,theHTMLtagforaparagraph,
allparagraphswillbecollectedandpassedtothescript.
Tip: HoveroverthenameofascriptintheScriptspanetohighlightpartsofthetemplatethatare
affectedbythescript.
Next,thescriptcanmodifytheselectedpiecesofcontent,usingvaluesfromtherecordthatismerged
withthetemplateatthetimethescriptruns.Itcan,forexample,hide,replaceoraddtextorchangethe
styleofthosepiecesofcontent.Thisishowscriptspersonalizedocuments.
Tip: Contentaddedbyascriptisn'tvisibleinDesignmode,butisvisibleandcanbeinspectedin
Previewmode.
Note: InaPrintcontext,thescriptsintheScriptspanerunonceforeachsectionandthenonce
foreachMasterPage(seeMasterPages).
Note: Thecontextforuserscriptsdoesnotresetacrossrecords.Thismeansthatifascriptuses
avariablethatisnotdeclaredorinitializedinthatscript,thevariableretainsitsvaluefromthepre-
Page 809