Snippets
A is a small, ready-to-use piece of content in a file. can be re-used within the same template, in all and . They can contain any contents that a can have, such as text, images, variable data, dynamic tables, etc.
When a snippet is added to a section or a , a reference to it is placed in the source code, but the content of the snippet itself is not added to the page. Modifying a snippet in a section that it has been added to, actually modifies the snippet's source. If a snippet is used in multiple locations (such as different contexts and sections), modifying one instance will modify all of them at once.
When a snippet is added to different sections or contexts, it is displayed according to the section's or 's stylesheet. This means that the same content can appear differently depending on the styles applied to the section or context, but it still has the exact same contents.
Adding a snippet
Before a snippet can be added to the content, the resource files that are related to the snippet, such as image files and CSS files, have to be imported into the template file. Drag and drop the files to the corresponding folders (Images and Stylesheets, respectively) on the Resources pane. If you want to use external images, see Images.
Drag the snippet itself to the Snippets folder on the Resources pane, or create a new snippet from an existing piece of content in the template (see Creating a snippet).
To export a snippet from your template, drag or copy/paste it out of the Snippets folder to a folder on the local hard drive.
To add the snippet to the content of a section, drag the snippet from the Snippets folder on the Resources pane to the desired location in a section.
It is also possible, and often useful, to insert a snippet or part of it, using a script. See Loading a snippet via a script.
Creating a snippet
To turn a parts of a letter or email into a snippet for reuse in the content of a template:
- Select the part that should be saved in a snippet.
- Right-click the selection, point to and click Create.
- Right-click the new snippet on the Resources pane in the Snippets folder and rename it.
JSON Snippets
JSON Snippets are that contain pieces of JSON data instead of HTML. Just like HTML snippets, JSON snippets are stored in the Snippets folder on the Resources pane, but their file names should end in '.json'.
JSON Snippets cannot be inserted into the content directly, but they can be accessed via a script using the function loadjson(): var json_data = loadjson("snippets/snippet.json"); results.html(json_data.field1);
See also: Write your own scripts.
|