Tagged template string function that converts MJML to HTML string
npm install tag-mjml![]()
A simple yet powerful module to allow you to use ES6 tagged template strings for rendering (generating HTML) of MJML email templates using dynamic substitutions, etc.
Module takes care of automatic escaping/converting variables for HTML.
So, something as crazy as below works just fine:
``ts
const mjml = require('tag-mjml')({ beautify: true });
const companyName = chalk
I love
My 🤘🏻 < {keyword('orange').bold Company};
const textSize = 62;
const htmlResult = mjml
font-style="italic"
font-size="${textSize}px"
color="#626262"
>
${companyName}
;`
and renders to nice HTML like this:
`html xmlns="http://www.w3.org/1999/xhtml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
>
So, now you don't need to repass MJML with Handlebars, etc, to have dynamic data binding.
Written in Typescript with 100% test coverage.