In my case, I used lodash to add HTML file contents to my suitelet
When you define your modules you can insert the lodash library at the end just like
define(['N/file', 'N/record', 'N/search', 'N/ui/serverWidget','./lodash.js'],
but at function you should not insert anything just like
function(file, record, search, serverWidget) {
Here is a sample of code to load a file and get his contents using lodash
/**
* @NApiVersion 2.x
* @NScriptType Suitelet
* @NModuleScope SameAccount
*/
define(['N/file', 'N/record', 'N/search', 'N/ui/serverWidget','./lodash.js'],
/**
* @param {file} file
* @param {record} record
* @param {search} search
* @param {serverWidget} serverWidget
*/
function(file, record, search, serverWidget) {
/**
* Definition of the Suitelet script trigger point.
*
* @param {Object} context
* @param {ServerRequest} context.request - Encapsulation of the incoming request
* @param {ServerResponse} context.response - Encapsulation of the Suitelet response
* @Since 2015.2
*/
function onRequest(context) {
var templateFile = file.load({
id: 'filePath'
});
//for example.
var compiled = _.template(templateFile.getContents());
}
return {
onRequest: onRequest
};
});
Note:
I inserted the file to the same location as my suitelet in the file cabinet that why I used this relative path (./lodash.js), use the full path if the suitelet is not at the same file.