Trying to render a nunjucks template but getting Error: template not found: email.html
.
server/
views/
email/
email.html
workers/
email.worker.js
//email.worker.js
function createMessage(articles) {
console.log(__dirname) // /<path>/server/workers
nunjucks.configure('../views/email/');
return nunjucks.render('email.html', articles);
}
No idea what's wrong here.
I had the same issue my solution was using path module:
const njk = require('nunjucks');
return njk.render(path.resolve(__dirname, '../views/email/' + 'email' + '.html'), articles);