2021.1

Table Of Contents
Then the Standard scripts are executed, once for each section, in the order in which they
appear in the Scripts pane.
Standard scripts can change the contents of the current section in a template.
This type of script must have a selector: text, an HTML element and/or a CSS selector (see
"Writing your own scripts" on page867 and "Selectors in Connect" below).
Running a template script starts with looking in the current section for pieces of content that
match the script's selector.
Important to note is that if nothing matches the selector, the script is not executed.
In a Print context, the Standard scripts in the Scripts pane run once for each section and then
for each Master Page (see "Master Pages" on page498). Next, each processed Master Page is
put behind every page to which it should be applied.
Scripts are NOT executed again for every page.
Finally, Post Pagination Scripts run, in the order in which they appear in the Scripts pane
(see "Post Pagination Scripts" on page919).
Post Pagination Scripts are run in a Print context after the content has been paginated.
Because they can search through the output of all Print sections, and modify Print sections (one
at a time), they may be used to create a Table Of Contents (TOC), as explained in the topic:
"Creating a Table Of Contents" on page921.
Note
Any JavaScript files included in a section run after the scripts in the Scripts pane.
Selectors in Connect
Selectors are patterns used to select one or more HTML elements. They were originally
developed to be able to define the layout of web pages without touching their content, through
Cascading Style Sheets (CSS). In Connect, since each section in a Connect template is in fact
an HTML file (see "Editing HTML" on page626), the very same selectors can be used in style
sheets (see "Styling templates with CSS files" on page738) and template scripts (see
"Personalizing content" on page780 and "Writing your own scripts" on page867). Using
selectors for scripting can increase the speed with which a template and data are merged; see
"Use an ID or class as selector" on page883.
Standard CSS selectors
Selectors are made up of one or more of the following components:
Page 888