UNPKG

@faire/mjml-react

Version:

React component library to generate the HTML emails on the fly

28 lines (27 loc) 778 B
import { minify as htmlMinify } from "html-minifier"; import mjml2html from "mjml"; import { renderToMjml } from "./renderToMjml"; export function render(email, options = {}) { const defaults = { keepComments: false, beautify: false, validationLevel: "strict", }; const parseResults = mjml2html(renderToMjml(email), { ...defaults, ...options, minify: undefined, }); if (options.minify) { return { html: htmlMinify(parseResults.html, { caseSensitive: true, collapseWhitespace: true, minifyCSS: true, removeComments: true, removeEmptyAttributes: true, }), }; } return parseResults; }