Yogiben:pretty-email and your own templates


Hi there,

I am using yogiben:pretty-email and it works great. My only problem is that I would love to modify the handlebar templates, or supply my own, but I can not figure out how to do it. I filed an issue on the github repository, but figured I ask here as well.



The only way I could get this to work was to add the package cmather:handlebars-server to my application, which will scan files with the extension .handlebars on my server. They are then added to a global variable Handlebars.templates.

Let’s assume I have server/lib/templates/myTemplate.handlebars, I can then call PrettyEmail.send(Handlebars.templates.myTemplate, {...})' and it will use my template.

In order to override the Accounts.emailTemplates set by PrettyEmail, I had to do

  Accounts.emailTemplates.enrollAccount.html = function(user, enrollAccountUrl) {
    var options = _.extend({}, PrettyEmail.defaults.enrollAccount,{
      subject: Accounts.emailTemplates.enrollAccount.subject(user),
      buttonUrl: enrollAccountUrl
    return PrettyEmail.render(Handlebars.templates.myTemplate, options);