I have a command line function which is pretty straight forward to add a Mandrill template.
var fs = Npm.require('fs');
this.addMandrillTemplate = function(templateName, options) {
var requestUrl = "https://mandrillapp.com/api/1.0/templates/add.json";
/** here is the problem. How do I look up the template? */
var templatePath = "";
Meteor.http.post(requestUrl, {
"key": process.env.MANDRILL_KEY,
"name": "Example Template",
"from_email": "from_email@example.com",
"from_name": "Example Name",
"subject": "example subject",
"code": fs.readFileSync(templatePath),
"text": "Example text content",
"publish": false,
"labels": [
"example-label"
]
}, function(err, data) {
});
}
So the idea is I will read a file path based on the name of a template name, open it, read it, then pass the value of its HTML to the "code" key.
So I imagine there must be SOME mechanism in the background looking up these templates paths and injecting them in order for Meteor to do what it does. I am hoping to get something like this, when all is said and done:
{
"invitationEmail": "/Users/me/code/my_project/client/templates/invitation_email.html"
}