Enonic version: XP 6.1.1
OS: Ubuntu
Nashorn supports the “load” function to import external content into the runtime. I can succesfully load scripts from external resources.
Example is use with momentjs. http://momentjs.com/
loadAsset('moment', 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js');
function loadAsset ( functionIdentifier , src ){
if (typeof functionIdentifier != 'function') {
log.info("Load Asset: " + functionIdentifier + " src: " + src );
load( src );
}
};
exports.loadAsset = loadAsset;
And succesfully use in a controller like this:
var time = new moment( comment.createdTime ).format("LLL");
I use webjars and I would like to load the resource from the webjars path. Does anyone know what the path looks like is it accessible ?