2020.2

Table Of Contents
l
Right-click a snippet and select Copy Resource Location to copy the relative path
of the snippet to the clipboard. It may then be pasted into a script.
Remote snippets are retrieved in the same way, except that the file extension should be
.rhtml instead of .html. If it is a remote JSON snippet, the file extension is .rjson.
Again, note that the name of the snippet must be exactly the same as in the Snippets folder.
For more examples, see "loadhtml()" on page1281 and "loadjson()" on page1285.
Loading part of a snippet
When a snippet contains a part that can be identified by a selector, that selector can be used to
load that part of the snippet into a template.
In script, use the following code:
results.loadhtml(snippets/nameofthesnippet.html, selector)
See "loadhtml()" on page1281 for more information about this function.
Loading a snippet, depending on the value of a data field
To load a snippet depending on the value of a data field, you have to add a condition to the
script.
Example
The following script evaluates if the value of the LANGUAGE field in the record is ‘En’. If so, the
snippet is added to the content.
if (record.fields.LANGUAGE == En’) {
results.loadhtml(snippets/nameofthesnippet.html);
}
Another example is given in a how-to; see Load a snippet based on a data field value.
Loading part of a snippet, based on the value of a data field
When a snippet contains a part that can be identified by a selector, that selector can be used to
load that part of the snippet into a template. It is possible to do this, based on the value of the
Page 882