Search code examples
ejsnetsuitesuitescriptsuitescript2.0

How to use EJS (Embedded JavaScript templates) in NetSuite with SuiteScript 2.0


I want to use EJS in my SuiteScript with the 2.0 APIs. I wonder if EJS is supported by NetSuite by default (like jQuery) or I have to go some extra steps to do so.

Particularly, I hope to use var page = new EJS({url: urlString}).render(dataOptions)

Thanks!


Solution

  • You can use any AMD-compatible library in SuiteScript by uploading the source file to the File Cabinet and including it as a dependency in your script module. As long as EJS provides an AMD-compatible format, you should have no problem adding it to a script.

    Remember that all server-side SuiteScript runs on Rhino which only supports ECMA 5.1, so if the library contains a bunch of ES6+ stuff, it will only work client-side, and will likely error out server-side.