andris9/Nodemailer — Issue #71: Adding templating functionality
Author: andris9
Created: 2012-03-08 21:21:54+00:00
State: open
Labels: Feature request

I'm considering adding templating functionality to Nodemailer (similar as it is with node_mailer). Not reaaly sure yet, what would be the best way for it.

Probably something in the lines of

// create template
myTemplate = nodemailer.createTemplate({
engine: "mustache",
templateFile: "/path/to/file"
});

// setup mail options with template
mailOptions = {
...,
html: myTemplate({
name: "Santa Claus",
title: "mr.",
phone: "+1 (234) 567 8901"
})
}

The returned template value would be a function that takes template options as a parameter and returns a paused Stream object, that will start rendering on stream.resume(). Currently html and text options do not accept streams as input but this should not be very hard to change.