{"action":"created","issue":{"url":"https://api.github.com/repos/niftylettuce/node-email-templates/issues/149","labels_url":"https://api.github.com/repos/niftylettuce/node-email-templates/issues/149/labels{/name}","comments_url":"https://api.github.com/repos/niftylettuce/node-email-templates/issues/149/comments","events_url":"https://api.github.com/repos/niftylettuce/node-email-templates/issues/149/events","html_url":"https://github.com/niftylettuce/node-email-templates/issues/149","id":113978125,"number":149,"title":"Issues with node-email-templates, Express and Handlebars","user":{"login":"custa1200","id":161224,"avatar_url":"https://avatars.githubusercontent.com/u/161224?v=3","gravatar_id":"","url":"https://api.github.com/users/custa1200","html_url":"https://github.com/custa1200","followers_url":"https://api.github.com/users/custa1200/followers","following_url":"https://api.github.com/users/custa1200/following{/other_user}","gists_url":"https://api.github.com/users/custa1200/gists{/gist_id}","starred_url":"https://api.github.com/users/custa1200/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/custa1200/subscriptions","organizations_url":"https://api.github.com/users/custa1200/orgs","repos_url":"https://api.github.com/users/custa1200/repos","events_url":"https://api.github.com/users/custa1200/events{/privacy}","received_events_url":"https://api.github.com/users/custa1200/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-29T04:33:21Z","updated_at":"2015-11-11T06:40:35Z","closed_at":null,"body":"Hi I have a setup that I can send emails with so long as I do not use any handlebars partials. I am using the ExpressJS 4.x built in Handlebars\" hbs = require('hbs')\" in app.js My setup looks like the following:\r\n```\r\napp.js\r\n|-routes\r\n| |-index.js\r\n| |-send-mail.js\r\n|-views\r\n| |-email-templates\r\n|   |-contact\r\n|     |-html.hbs\r\n| |-partials\r\n    |-email\r\n      |-page-header.hbs\r\n      |-page-footer.hbs \r\n```\r\n\r\nI am wanting to define all my email routes in the send-mail.js route file, but that file does not seem to respect all the Handlebars setup including registering the partials and exposing the locals variables from app.js. My send-email.js looks like:\r\n```\r\nvar express = require('express');\r\nvar path = require('path');\r\nvar EmailTemplate = require('email-templates').EmailTemplate;\r\nvar nodemailer = require('nodemailer');\r\nvar wellknown = require('nodemailer-wellknown');\r\n\r\nvar router = express.Router();\r\n\r\nvar transporter = nodemailer.createTransport({\r\n    service: 'Gmail',\r\n    auth: {\r\n        user: 'xxx@gmail.com',\r\n        pass: 'xxx'\r\n    }\r\n});\r\n\r\nvar defaultMailOptions = {\r\n    from: 'xxx', // sender address\r\n    toOwner: 'xxx'\r\n};\r\n\r\nrouter.post(\"/contact\", function(req, res) {\r\n    console.log(\"DIRECTORY NAME: \" + __dirname); ///Users/custa/github/Portfolio/portfolioapp/routes\r\n    var templatesDir = path.join(__dirname, '..', 'views', 'email-templates', 'contact');\r\n    var template = new EmailTemplate(templatesDir, {\r\n        juiceOptions: {\r\n            preserveMediaQueries: false,\r\n            removeStyleTags: false\r\n        }\r\n    });\r\n    var body = req.body;\r\n    var currentMailOptions = defaultMailOptions;\r\n    currentMailOptions.subject = \"Contact Request\";\r\n    currentMailOptions.from = body.email;\r\n    currentMailOptions.senderName = body.name;\r\n    currentMailOptions.message = body.message\r\n\r\n    template.render(currentMailOptions, function (err, results) {\r\n        if (err) {\r\n            return console.error(err)\r\n        }\r\n\r\n        transporter.sendMail({\r\n            from: currentMailOptions.from,\r\n            to: currentMailOptions.toOwner,\r\n            subject: currentMailOptions.subject,\r\n            html: results.html,\r\n            text: results.text\r\n        }, function (err, responseStatus) {\r\n            if (err) {\r\n                return console.error(err)\r\n            }\r\n            console.log(responseStatus.message)\r\n        });\r\n    });\r\n\r\n    res.render('contact-success', {\r\n        title: 'Contact Success - Test'\r\n    });\r\n});\r\n\r\nmodule.exports = router;\r\n```\r\n\r\nBut when I post to \"/contact\" I have the following error in the console:\r\n\r\n```\r\nDIRECTORY NAME: /Users/custa/github/Portfolio/portfolioapp/routes\r\n{ [Error: The partial email/page-header could not be found]\r\n  description: undefined,\r\n  fileName: undefined,\r\n  lineNumber: undefined,\r\n  message: 'The partial email/page-header could not be found',\r\n  name: 'Error',\r\n  number: undefined }\r\n```\r\nThe \"contact/html.hbs\" file looks like the following:\r\n```\r\n<html>\r\n    <head></head>\r\n    <body>\r\n        {{>email/page-header}}\r\n        <h1>Contact Request - {{@sitename}}</h1>\r\n        <p>{{senderName}}, sent you the following message from your portfolio site.</p>\r\n        <p>{{message}}</p>\r\n        {{>email/page-footer}}\r\n    </body>\r\n</html>\r\n```\r\nsenderName and message work fine when the partials are commented out, but the partials  {{> xxx}} and the local {{@sitename}} do not work.\r\n\r\nHow do I get node-email-templates to use the Handlebars references that have been set up in App.js and power the non email portion of the site successfuly."},"comment":{"url":"https://api.github.com/repos/niftylettuce/node-email-templates/issues/comments/155682663","html_url":"https://github.com/niftylettuce/node-email-templates/issues/149#issuecomment-155682663","issue_url":"https://api.github.com/repos/niftylettuce/node-email-templates/issues/149","id":155682663,"user":{"login":"custa1200","id":161224,"avatar_url":"https://avatars.githubusercontent.com/u/161224?v=3","gravatar_id":"","url":"https://api.github.com/users/custa1200","html_url":"https://github.com/custa1200","followers_url":"https://api.github.com/users/custa1200/followers","following_url":"https://api.github.com/users/custa1200/following{/other_user}","gists_url":"https://api.github.com/users/custa1200/gists{/gist_id}","starred_url":"https://api.github.com/users/custa1200/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/custa1200/subscriptions","organizations_url":"https://api.github.com/users/custa1200/orgs","repos_url":"https://api.github.com/users/custa1200/repos","events_url":"https://api.github.com/users/custa1200/events{/privacy}","received_events_url":"https://api.github.com/users/custa1200/received_events","type":"User","site_admin":false},"created_at":"2015-11-11T06:40:35Z","updated_at":"2015-11-11T06:40:35Z","body":"@jeduan is there any chance that I give you access to my repo that you could have a little look?"}}