doc/components_2.md
The mjml-core package allows you to include external .mjml files
to build your email template.
<!-- header.mjml -->
<mj-section>
<mj-column>
<mj-text>This is a header</mj-text>
</mj-column>
</mj-section>
You can wrap your external .mjml files inside the default mjml > mj-body
tags to make it easier to preview outside the main template.
<!-- main.mjml -->
<mjml>
<mj-body>
<mj-include path="./header.mjml" />
</mj-body>
</mjml>
The MJML engine will then replace your included files before starting the rendering process.
You can include external .css files which will be inserted in the same way as using an mj-style tag. You need to specify that you're including a CSS file using the attribute type="css" attribute.
If you want the CSS to be inlined, you can use the css-inline="inline" attribute.
<!-- main.mjml -->
<mj-include path="./styles.css" type="css" />
<mj-include path="./inline-styles.css" type="css" css-inline="inline" />
You can also include external html files. They will be inserted the same way as when using an mj-raw tag. You need to specify that you're including an HTML file using the attribute type="html".
<!-- main.mjml -->
<mj-include path="./partial.html" type="html" />