Loading external libraries in scripts using docxtemplater recipe
-
Hi,
I have been using chrome-pdf and html-to-xlsx recipes with success, each template uses moment.js. In each template have just loaded moment.js in <script> tags in the <head> section of the template. This has worked well to make the moment.js library available to the template and the functions that are called in the template.
Now I am using docxtemplater, which has a blank template. I need to use a script to manipulate the data. What is the best way to make the moment.js library available within this script?
Cheers.
-
You can do something like this
const moment = require('moment') function beforeRender(req, res) { req.data.modification = moment().format() }
-
Great, thanks. That was easy.
Cheers.