2019.2

Table Of Contents
Tip
To quickly get the location of an HTML snippet in the template resources, right-click the snippet in
the Resources pane and select Copy Resource Location.
The path to a remote HTML snippet can be copied from the snippet's properties: right-click the
snippet in the Resources pane and select Properties.
Examples
This script loads a local HTML snippet (from the Resources panel) directly into the matched
elements
results.loadhtml("snippets/snippet.html");
The following script loads a local HTML snippet (Resources panel) into a variable. The
replaceWith() command is used to replace the element(s) matched by the script's selector with
the contents of the snippet.
var mysnippet = loadhtml('snippets/snippet.html');
results.replaceWith(mysnippet);
Same result as the previous script, but a different notation:
results.replaceWith(loadhtml('snippets/snippet.html'));
The following script loads a snippet into a variable and finds/replaces text in the variable before
inserting the content into the page. The second find command also adds formatting to the
replacing text.
var mysnippet = loadhtml
('file:///C:/Users/PParker/Documents/Example.html');
mysnippet.find('@var1@').text('OL Connect 1');
mysnippet.find('@var2@').html('<i>OL Connect 2</i>').css('text-
decoration','underline');
results.replaceWith(mysnippet);
This last script loads a remote snippet into a variable and retrieves an element from the snippet
using query().
var mysnippet = loadhtml('http://www.somewebsite.com/text-root-
wrapped.html');
var subject = query("#subject", mysnippet).text();
Page 1340