Overview
This node compiles MJML email templates by combining header, body, and footer MJML code sections. It processes the combined MJML with Handlebars templating using input JSON data, then converts it to HTML. Optionally, it minifies the resulting HTML and generates a plain text version of the email content. This node is useful for dynamically generating responsive email templates in workflows, such as sending customized marketing emails or notifications.
Use Case Examples
- Generate a complete email template by providing separate MJML header, body, and footer sections, then compile them into HTML and plain text for sending.
- Use Handlebars expressions in the MJML body to dynamically insert data from previous workflow steps before compiling.
Properties
| Name | Meaning |
|---|---|
| Header (MJML) | MJML code for the email header section, required for template compilation. |
| Body (MJML) | MJML code for the main body of the email, supports Handlebars templating, required for compilation. |
| Footer (MJML) | MJML code for the email footer section, required for template compilation. |
| Minify | Boolean flag to minify the resulting HTML output to reduce size and remove unnecessary whitespace and quotes. |
Output
JSON
html- The compiled HTML output of the MJML template, optionally minified.text- The plain text version of the compiled HTML, suitable for email clients that do not support HTML.
Dependencies
- mjml library for MJML to HTML compilation
- html-minifier library for optional HTML minification
- handlebars library for templating with input JSON data
- html-to-text library to generate plain text from HTML
Troubleshooting
- Ensure the MJML syntax in header, body, and footer is valid to avoid compilation errors.
- If Handlebars expressions fail, verify the input JSON data contains the referenced fields.
- Minification may cause issues if the HTML relies on specific whitespace or attribute formatting; disable minify if problems occur.
- Common errors include MJML validation errors or missing template placeholders; review error messages for details.
Links
- MJML Official Website - Documentation and resources for MJML email template language.
- Handlebars Templating - Documentation for Handlebars templating syntax used in MJML body.
- html-minifier - Library used to minify HTML output.
- html-to-text - Library used to convert HTML to plain text.