mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 18:11:40 -05:00
36 lines
No EOL
957 B
JavaScript
36 lines
No EOL
957 B
JavaScript
_.forEach(Telescope.email.emails, (email, key) => {
|
|
|
|
// template live preview routes
|
|
Picker.route(email.path, (params, req, res) => {
|
|
|
|
let html;
|
|
|
|
// if email has a custom way of generating test HTML, use it
|
|
if (typeof email.getTestHTML !== "undefined") {
|
|
|
|
html = email.getTestHTML.bind(email)(params);
|
|
|
|
} else {
|
|
|
|
// else get test object (sample post, comment, user, etc.)
|
|
const testObject = email.getTestObject(params._id);
|
|
|
|
// get test object's email properties
|
|
const properties = email.getProperties(testObject);
|
|
|
|
// then apply email template to properties, and wrap it with buildTemplate
|
|
html = Telescope.email.buildTemplate(Telescope.email.getTemplate(email.template)(properties));
|
|
|
|
}
|
|
|
|
// return html
|
|
res.end(html);
|
|
|
|
});
|
|
|
|
// raw template
|
|
Picker.route("/email/template/:template", (params, req, res) => {
|
|
res.end(Telescope.email.templates[params.template]);
|
|
});
|
|
|
|
}); |