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.67k stars 337 forks source link

Render from string instead of file? #340

Closed 1valdis closed 5 years ago

1valdis commented 5 years ago

Is it possible to render an email content from string instead of path to a template file? If, for example, my pug template is stored in a DB and doesn't have any references to other pug templates.

Edit: Closing it because I've found that it's possible to supply custom render function:

const email = new Email({
  render: async (view, locals) => 'foobar'
})

const rendered = await email.render('...', {...}) // 'foobar'