Skip to content

Commit 4e481e1

Browse files
committed
server/utils/renderMjml: add types & named export
1 parent 380366f commit 4e481e1

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

server/utils/renderMjml.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
/* eslint-disable consistent-return */
12
import mjml2html from 'mjml';
23

3-
export default (template) => {
4+
/** Parse template string containing mjml tags into html for nodemailer.SendMailOptions.html */
5+
export function renderMjml(template: string): string | undefined {
46
try {
57
const output = mjml2html(template);
68
return output.html;
79
} catch (e) {
810
console.error(e);
9-
// fall through to null
11+
// fall through to undefined (null is not valid for nodemailer.SendMailOptions.html)
12+
return undefined;
1013
}
11-
12-
return null;
13-
};
14+
}

server/views/mail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import renderMjml from '../utils/renderMjml';
1+
import { renderMjml } from '../utils/renderMjml';
22
import { mailLayout } from './mailLayout';
33
import { consolidationMailLayout } from './consolidationMailLayout';
44

0 commit comments

Comments
 (0)