yads / nodemailer-express-handlebars

A plugin for nodemailer that uses express-handlebars view engine to generate emails
87 stars 30 forks source link

partialsDir not used? #9

Closed ekkis closed 8 years ago

ekkis commented 8 years ago

I use handlebars for my site with the default layout views/, views/layouts/, views/partials/. now I want to use it for mails and I've created a views/mail/ - however, I want to share partials. so I have it configured like this:

var hbs = require('nodemailer-express-handlebars');
var mail = smtp.createTransport(...);
mail.use('compile', hbs({extName: '.html', viewPath: 'views/mail', viewEngine: {partialsDir: 'views/partials'}});

but when I try to use a template, I get an error:

Unhandled rejection Error: The partial Test could not be found at Object.invokePartial (/Users/ekkis/xx/www/node_modules/handlebars/dist/cjs/handlebars/runtime.js:266:11) at Object.invokePartialWrapper as invokePartial at Object.eval (eval at createFunctionContext (/Users/ekkis/xx/www/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), :10:28) at main (/Users/ekkis/xx/www/node_modules/handlebars/dist/cjs/handlebars/runtime.js:173:32) at ret (/Users/ekkis/xx/www/node_modules/handlebars/dist/cjs/handlebars/runtime.js:176:12) at ret (/Users/ekkis/xx/www/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:525:21) at ExpressHandlebars._renderTemplate (/Users/ekkis/xx/www/node_modules/express-handlebars/lib/express-handlebars.js:247:12) at ExpressHandlebars. (/Users/ekkis/xx/www/node_modules/express-handlebars/lib/express-handlebars.js:173:21)

what am I doing wrong?

ekkis commented 8 years ago

apparently I need to change the extension in the view engine's definition as well:

viewEngine: {extname: '.html', partialsDir: 'views/partials'}