0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00

Reworked EmailContentGenerator to async/await

refs https://github.com/TryGhost/Toolbox/issues/292

- Makes the code more readable
This commit is contained in:
Naz 2022-05-04 15:16:39 +08:00 committed by naz
parent 551bd5e511
commit 2d7bcdf80a

View file

@ -35,8 +35,8 @@ class EmailContentGenerator {
const data = _.defaults(defaults, options.data);
// read the proper email body template
return fs.readFile(path.join(this.templatesDir, options.template + '.html'), 'utf8')
.then(function (content) {
const content = await fs.readFile(path.join(this.templatesDir, options.template + '.html'), 'utf8');
// insert user-specific data into the email
const compiled = _.template(content);
const htmlContent = compiled(data);
@ -48,7 +48,6 @@ class EmailContentGenerator {
html: htmlContent,
text: textContent
};
});
}
}