Skip to content

Instantly share code, notes, and snippets.

@nicooprat
Last active June 13, 2020 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicooprat/d9564d1243d052f0b33a2d222001b2b8 to your computer and use it in GitHub Desktop.
Save nicooprat/d9564d1243d052f0b33a2d222001b2b8 to your computer and use it in GitHub Desktop.
Render HTML from MJML
const mjml2html = require('mjml')
renderer.renderToString(app, (err, mjml) => {
if (err) throw err
// Remove illegal MJML attribute added by Vue to avoid warnings
mjml = mjml.replace('data-server-rendered="true"', '')
// Compile MJML to raw HTML
const { html, errors } = mjml2html(mjml)
if (err) throw errors
console.log(html)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment