Closed alexander-tsig closed 8 years ago
Wow, great. I will check it right now.
In my opinion, that is a bit strange because you need req
and res
. I'm using Swig and noticed that this kind of code also works:
keystone.get('custom engine')('templates/emails/register.swig', {name: 'John Example'}, function(err, result) {
console.log(err, result);
});
I'd like to know what is the most preferred way to do this and how to get rid of that custom engine
part.
Here are the defaults when calling the Email class
var defaultConfig = {
templateExt: 'jade',
templateEngine: require('jade'),
templateBasePath: path.normalize(path.join(__dirname, '..', 'templates', 'helpers', 'emails')),
mandrill: {
track_opens: true,
track_clicks: true,
preserve_recipients: false,
inline_css: true
},
// Mandrill template
templateMandrillName: null,
templateForceHtml: false // Force html render
};
Have you tried setting the template up when initiating the class. I have not tried another engine but this might work
var Email = new keystone.Email({
templateName: 'template-name',
templateExt: 'swig',
templateEngine: require('swig'),
templateBasePath: '/set-your-path'
});
Hey, Doesn't seem to work with nunjucks. My options are:
templateName: 'confirm',
templateExt: 'html',
templateEngine: require('nunjucks'),
templateBasePath: '/templates/emails'
I get an error:
TypeError: object is not a function
at null.<anonymous> (/node/project_name/node_modules/keystone/lib/email.js:218:46)
Any way to set the template engine and extension globally?
We're closing all questions and support requests to keep the issue tracker unpolluted. Please ask this question on Stackoverflow or Gitter instead!
Yes it's possible :
exemple : https://github.com/gilloud/AnnouncementManager/blob/master/routes/views/mail.js