Registry / development / mjml-raw-4-terser

mjml-raw-4-terser

JSON →
library4.15.5jsnpmunverified

An MJML component that outputs raw HTML without MJML processing. It is part of the mjml-4-terser package (version 4.15.5), a fork aiming to reduce bundle size. Releases follow upstream MJML. Key differentiator: allows embedding arbitrary HTML, templating, or meta tags, and can be placed before the doctype using position='file-start'. Caution required with minification: wrap template syntax in htmlmin:ignore comments to avoid parsing errors.

npm install mjml-raw-4-terser
INSTALL
IMPORT
SIG · MJML-RAW-4-TERSER
M
mjml-raw-4-terser
developmentjavascriptv4.15.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mjml-raw component
<mj-raw>...</mj-raw>
<mjml-raw>...</mjml-raw>
The tag is <mj-raw>, not <mjml-raw>. It is not a JavaScript import; it is used inside MJML templates.
position attribute
<mj-raw position="file-start">...</mj-raw>
<mj-raw position="file-top">...</mj-raw>
Only valid value is 'file-start'. Placed directly inside <mjml> but outside <mj-head> and <mj-body>.
htmlmin:ignore comments
<!-- htmlmin:ignore -->{% if foo < 5 %}<!-- htmlmin:ignore -->
Not wrapping template syntax with ignore tags before minification
Required when using minify option and containing '<' characters to prevent parsing errors.

Shows how to embed raw HTML inside an MJML template using the mj-raw tag.

<mjml> <mj-body> <mj-raw> <!-- Custom HTML here --> <div style="color:red;">Raw content</div> </mj-raw> </mj-body> </mjml>
Debug
Known issues
gotchaIf you use mj-raw to add templating language (e.g., {% if foo < 5 %}) and enable minification, a Parsing error occurs because of '<' characters.
fix
Wrap template syntax with <!-- htmlmin:ignore -->...<!-- htmlmin:ignore -->
affects: *
gotchamj-raw placed before <!doctype html> using position='file-start' will have its content minified into a single line if minification is enabled, potentially breaking multi-line content.
fix
Wrap multi-line content with <!-- htmlmin:ignore --> tags
affects: *
gotchamj-raw is an 'ending tag': cannot contain other MJML components, only HTML.
fix
Do not nest MJML components inside <mj-raw>
affects: *
Errors
Common errors & fixes
Parsing error: unexpected character '<'
Template syntax (e.g., {% if foo < 5 %}) inside mj-raw when minification is on.
fix
Wrap the template syntax with <!-- htmlmin:ignore -->...<!-- htmlmin:ignore -->
MJML component not allowed inside mj-raw
Trying to use MJML tags (e.g., <mj-text>) inside <mj-raw>.
fix
Remove MJML components from inside <mj-raw>; it only accepts HTML.
Unknown attribute position='file-top'
Using an incorrect value for the position attribute.
fix
Use position='file-start' (the only valid value).
Upgrade
Version history
4.15.5latest on npm
Audit
Dependencies
mjml-4-terserrequiredThis package is a fork of MJML's core; mjml-raw is a built-in component.
Agent activity
36 hits · last 30 days
node
28
Resources
mjml-raw-4-terser — npm install mjml-raw-4-terser · libregistry