Syntax of the field in edit mode
MyFile.txt
Just a single file name loads the file from the library:
<Current Web>/modulerixAjaxContent
-site-MyFile.txt
With the tag -site- loads the file from the library:
<Root Web of Site Collection>/modulerixAjaxContent
-root-MyFile.txt
With the tag -root- loads the file from the library:
<Root Web of Root Site Collection>/modulerixAjaxContent
/MyLib/MyFile.txt
With a leading / or http the file is loaded from the specified url.
MyFile.txt{"mytoken": "mytokenvalue"}
A additional object (JSON-format) to specify tokens with values you want to replace before the content is injected.
MyFile.txt{"mytoken": "-noencode-mytokenvalue"}
With the tag -noencode- on a token value the string will not be html encoded (be careful!).
Global JavaScript object and token replacement
The global JavaScript object $.mxal is available to help you writing reusable HTML templates and JavaScript libraries with relative pathes to the current web or site collection. The object has the following properties (you can extend):
weburl The url to the current web
webliburl The url to the library of the current web
siteurl The url to the current site collection
siteliburl The url to the library of the current site
rootliburl The url to the library of the root site
Each of these properties can also be used as a string replace token in your files. Sample: Each string "-weburl-" in your file will get replaced with the url of the current web.
Sample
We have created a sample with a PrettyPhoto gallery. The JavaScript libraries are stored in the root website collection. Now, in any website we can create a picture library with the name "Pictures" and upload some pictures. In any place in this website we can show the gallery now with -root-PhotoGallery.txt.
Tutorial (PrettyPhoto Gallery Sample)
Demo (PrettyPhoto Gallery Sample)
If this solution is not exactly what you are looking for, we can create your solution as per your requirement.