2022.2

Table Of Contents
Example
Thefollowingscriptaddsanimagecalled'dog.jpg'tothecontentofthetemplateiftheimagecanbe
foundinthetemplate'sresources:
const image = merge.template.images.find(image => image.name == 'dog.jpg');
if (image) {
results.after(`<img src=${image.path}>`);
}
masterpage
ThemasterpageobjectisusedtosetaMasterPage'sheaderandfooterortoreplaceitsentireHTML
body.ItcanonlybeaccessedinControlScripts(see"ControlScripts"onpage838and"ControlScript
API"onpage1271).Tryingtoaccessitinanothertypeofscriptwillresultinanerror.
NotethatMasterPagesareonlyusedinaPrintcontext(see"MasterPages"onpage462).
Inscript,MasterPagesareretrievedviathemasterpagesArraywhichcontainsallMasterPagesinthe
currenttemplate(see"template"onpage1292).
Forexample:
var myMasterpage = merge.template.masterpages["Master page 1"];.
Functions and fields
Field Type Description
"html()"on
page1291
GetsorsetstheHTMLofthebodyelement.
"margins"on
page1311
Margins AllowstosettheheaderandfooterofaMasterPage,usingaMeasurementstring,forexample:"2in"
(thissetsamargintotwoinches).
html()
InaControlScript,thehtml()functionofasectionorMasterPagecanbeusedtogettheinitialcon-
tentsofits<body>,andmodifythem.Thismakesitpossible,forexample,topopulateasectionor
MasterPagewithelementsretrievedfromaContentManagementsystem,beforeStandardScripts
run.
html()
Getstheinitialcontentsofthe<body>ofasectionorMasterPage.
Page 1192