2021.2

Table Of Contents
Tip
It is possible to open and edit any HTML or JSON file in the Designer: select File > Open,
select All files (*.*) as the file type and then select a HTML or JSON file.
About JSON Snippets
JSON Snippets are snippets 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 name should end in '.json'.
JSON Snippets cannot be inserted into the content directly, but they can be accessed via a
script using the loadjson() function:
var json_data = loadjson("snippets/snippet.json");
results.html(json_data.field1);
See also: "Writing your own scripts" on page877.
For an example in which JSON snippets are being used to localize a template, see this how-to:
Localizing templates using json.
Adding a snippet to the Resources
Here's how to add a snippet to the Resources of a template.
1. Before adding a snippet, import the resource files that are related to the snippet, such as
image files and CSS files, 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" on page727.
2. Create a new snippet from an existing piece of content in the template (see "Creating a
snippet" on page744), or drag the file that contains the snippet into the Snippets folder
on the Resources pane.
If the added snippet is not UTF-8 encoded you will be asked to select its encoding. The
snippet will then be converted and saved in the template as UTF-8 encoded file.
Page 742