Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for @forwardemail, @ladjs, @cabinjs, @spamscanner, and @breejs.
This is related to #88, but it deserves better documentation and I have a modestly different solution.
The problem is: out of the box, dustjs partials don't work that well, because the file references are resolved using a different system to the initial templates. The views directory can be passed to the main new Email(), but templates fail to render with messages like:
{ Error: ENOENT: no such file or directory, open './shared/html.dust'
cause:
{ Error: ENOENT: no such file or directory, open './shared/html.dust'
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: './shared/html.dust' },
isOperational: true,
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: './shared/html.dust' }
In other words, passing the views root into the render for consolidate, as well as into the initial configuration, works fine. However, it would be nicer if we didn't to do that, or that it would be documented.
This seems to only be necessary in practice for dustjs, so I don't know whether a new config item for that might be better.
This is related to #88, but it deserves better documentation and I have a modestly different solution.
The problem is: out of the box, dustjs partials don't work that well, because the file references are resolved using a different system to the initial templates. The views directory can be passed to the main
new Email()
, but templates fail to render with messages like:For reference, my template reads:
The issue can be replicated by the simple script:
When run, even with a
shared/html.dust
file in place, we get the error above.It's easy to resolve by modifying the
locals
to:In other words, passing the views
root
into therender
for consolidate, as well as into the initial configuration, works fine. However, it would be nicer if we didn't to do that, or that it would be documented.This seems to only be necessary in practice for dustjs, so I don't know whether a new config item for that might be better.