2022.2

Table Of Contents
('file:///C:/Users/PParker/Documents/Example.html');mysnippet.find('@var1@').text('OLCon-
nect1');mysnippet.find('@var2@').html('<i>OLConnect2</i>').css('text-
decoration','underline');results.replaceWith(mysnippet);Thislastscriptloadsaremotesnippet
intoavariableandretrievesanelementfromthesnippetusingquery().varmysnippet=loadhtml
('http://www.somewebsite.com/text-root-wrapped.html');varsubject=query("#subject",mys-
nippet).text();results.append("<pstyle='font-weight:bold;'>"+subject+"</p>");loadhtml(loc-
ation,selector)RetrievesspecificcontentfromthespecifiedHTMLfile.locationStringcontaininga
paththatcanbeabsoluteorrelativetothesection/context.Usesnippets/<snippet-name>to
retrievethecontentfromanHTMLfileresidingintheSnippetsfolderontheResourcespanel.In
ordertoretrievefilesfromoutsidethetemplatethefileprotocolissupportedaswellasthehttp/ht-
tpsprotocols.ThecompletesyntaxofafullyqualifiedURLwiththe"file"protocolis:
file://<host>/<path>.Ifthehostis"localhost",itcanbeomitted,resultinginfile:///<path>,for
example:file:///c:/somefolder/somecontent.html.Whenusingthehttp/httpsprotocol,remember
thatonlyabsolutepathsaresupportedinsideremotesnippets(see"Remotesnippets"on
page1).ToquicklygetthelocationofanHTMLsnippetinthetemplateresources,right-clickthe
snippetintheResourcespaneandselectCopyResourceLocation.ThepathtoaremoteHTML
snippetcanbecopiedfromthesnippet'sproperties:right-clickthesnippetintheResourcespane
andselectProperties.selectorString.ThesuppliedselectorshouldconformtoCSSselector
syntaxandallowsyoutoretrieveonlythecontentofmatchingelements.Iftheselectedelementis
aDynamicTable,theretrievedHTMLwillcontaintheexpandedtable.ExamplesThisscriptloads
aspecificelementfromasnippetandusesthattoreplacetheresults(theHTMLelementorsetof
HTMLelementsmatchedbytheselectorofthescript;see"results"onpage1).varmysnippet=
loadhtml('snippets/snippet-selectors.html','#item3');results.replaceWith(mysnippet);Thisscript
loadsthechildrenoftheselectedelement.varsnippet=loadhtml('file:///C:/User-
s/PParker/Documents/Example.html','foobar').children();results.replaceWith(snippet);Thenext
scriptloadsaremotesnippet(see"Remotesnippets"onpage1),looksforanH1headingand
usesthattext.varpost=loadhtml('snippets/post.rhtml');varh1=query('h1',post).text();res-
ults.text(h1);Anotherexampleisgiveninthefollowinghow-to:Usingaselectortoloadpartofa
snippet."onpage1);forJSON,useloadjson()("loadjson()"onpage1184).
Tip: Externalcontentisnotloadedwhileeditingascript.Totestascriptthatloadsexternalcon-
tent,youcandoapreflight;see"DoingaPreflight"onpage818.
loadtext(location)
Returnsthecontentofatextfile.Thefileextensiondoesn'thavetobe.txt.ItmayalsobeaJavaScript
file(.js)orastylesheet(.css),forinstance.
location
Page 1187