forwardemail / email-templates

Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for @forwardemail, @ladjs, @cabinjs, @spamscanner, and @breejs.
https://forwardemail.net/docs/send-emails-with-node-js-javascript
MIT License
3.66k stars 339 forks source link

renderAll doesn't render all #366

Closed simllll closed 5 years ago

simllll commented 5 years ago

I was expecting that renderAll will render all files in one directory, but instead it's hardcoded to text,html and subject. Just in case someone else runs into this too ;) Would be great to add this to the documentation, or even better if there would be an option to add some custom templates.

Regards Simon

niftylettuce commented 5 years ago

What else would you be rendering besides text/html/subject?

niftylettuce commented 5 years ago

Let me know!

simllll commented 5 years ago

In my case I use it for deeplinks for example.

Regards

niftylettuce commented 5 years ago

Can you share a snippet/example? I'm not sure what you're referring to for deeplinks. I only know that Nodemailer supports html, text, and subject.

simllll commented 5 years ago

I use only the render part of the library, and I use it for all type of notifications. Besides email this is apn, fcm, webpush, redis pubsub,.. E.g. the render part looks currently something like this:

const rendered = await template.renderAll(contentType, data);

        if (contentType === 'push') {
            rendered.deeplink = await template.checkAndRender('deeplink', contentType, data);
        }

        return rendered;

Regards

niftylettuce commented 5 years ago

I think that may be out of the scope of this library, since we use consolidate internally, it may be easier for you to directly use it.

Ref: https://github.com/tj/consolidate.js

PR is welcome though