Closed marcwhitbread closed 6 years ago
I'm not sure what you mean - can you be more elaborate with a code example? We do expose the send
and render
methods.
Something like...
.send({
template: 'some/path/to/mars',
message: {
to: 'elon@spacex.com'
},
locals: {
name: 'Elon'
}
})
OR
.send({
template: '../../some/path/to/mars',
message: {
to: 'elon@spacex.com'
},
locals: {
name: 'Elon'
}
})
How does it work?
If you look in the codebase, the render
method uses a function getTemplatePath
. You would either need to do one of two things:
email.render('/absolute/path', locals, true)
and instead of using this.getTemplatePath
it would simply set filePath
to the value /absolute/path
if the Boolean value was true
for isAbsolutePath
(e.g. in email.render(template, locals, isAbsolutePath = false)
.Awesome dude! I'll take a look and possibly go the PR route 👍
Thanks for the quick reply!
Actually @marcwhitbread - you might not even need a third argument!
https://nodejs.org/api/path.html#path_path_isabsolute_path
You could just use that inside the render
method, and if it was an absolute path then it would not attempt to lookup the template 😄
Going to re-open this- once we resolve/patch/PR we can close :smile:!
@marcwhitbread would love a PR ❤️ !
@niftylettuce Would that solve the issue? https://github.com/niftylettuce/email-templates/pull/329
thanks @pke, I've released v5.0.1 of email-templates which includes this PR
update docs are available too at https://github.com/niftylettuce/email-templates#absolute-path-to-templates
cc @marcwhitbread care to try it out?
Can I do something like template: 'content/some_key'? or '../content/some_key'?