Excellent, thanks!
D
danielsharvey
@danielsharvey
0
Reputation
2
Posts
1165
Profile views
0
Followers
0
Following
Posts made by danielsharvey
-
Documentation for incorporating helpers within extensions
Hi,
jsreport-xlsx utilises several mechanisms for incorporating
helpers.js
(see below fromjsreport-xlsx/src/index.js
). Can you please point me in the direction of the documentation for when these various mechanisms might apply and any specific documentation on their operation?Thanks!
Danielif (reporter.compilation) { reporter.compilation.resource('defaultXlsxTemplate.json', path.join(__dirname, '../static', 'defaultXlsxTemplate.json')) reporter.compilation.resource('helpers.js', path.join(__dirname, '../static', 'helpers.js')) }
and
return (reporter.execution ? Promise.resolve(reporter.execution.resource('helpers.js')) : FS.readFileAsync(path.join(__dirname, '../', 'static', 'helpers.js'), 'utf8')).then( (content) => { if (req.template.helpers && typeof req.template.helpers === 'object') { // this is the case when the jsreport is used with in-process strategy // and additinal helpers are passed as object // in this case we need to merge in xlsx helpers req.template.helpers.require = require req.template.helpers.fsproxy = require(path.join(__dirname, 'fsproxy.js')) return vm.runInNewContext(content, req.template.helpers) } req.template.helpers = content + '\n' + (req.template.helpers || '') })