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

Debugging tips for getting the path of nunjucks extend / include #298

Closed microcipcip closed 6 years ago

microcipcip commented 6 years ago

Hi, I am trying for hours to get nunjucks extend and include to work. I think I am missing the right path but have no idea how to debug it. Is there a way to see the full path of an include?

// structure
/utils/email.js
/templates/emails/default/html.njk
/templates/emails/default/fileToInclude.njk

// inside html.njk
{% include "./content.njk" %} // doesn't work
{% include "content.njk" %} // doesn't work

// config inside email.js
new Email({
  views: {
    root: 'templates/emails/',
    options: { extension: 'njk' }
  }
  ...
})

// 
email.send({
  template: 'default'
  ...
})
microcipcip commented 6 years ago

Hi, I have managed to find the right path, is from the root of the app. Why is not relative to what I have specified in the views.root object?

{% include "templates/emails/default/content.njk" %} // works
niftylettuce commented 6 years ago

@microcipcip have you been able to find this out? I would check consolidate and its usage with nunjucks.

microcipcip commented 6 years ago

@niftylettuce so email-templates does not alter the path? It is a issue coming from consolidate?