Some basic MJML Components to generate Mosaico Templates. Use at your own risk.
-
Clone the repo
-
npm installinside -
Copy
templates/demototemplates/name -
Edit
templates/name/index.mjml -
gulp build --tmpl nameto build the template -
When using Mailtrain, copy
templates/nametomailtrain/public/mosaico/templates/nameand enable the template in yourconfigfile. -
When using any other Mosaico build, rename
templates/name/index.htmltotemplates/name/template-name.htmland copy the template folder to your Mosaico installation.
mj-mosaico-dropzone is a self closing tag and can only be used once inside mj-container. This tag renders the block dropzone in Mosaico.
<mj-mosaico-dropzone />mj-mosaico-block-begin and mj-mosaico-block-end are self closing tags and can only be used inside mj-container. They can span multiple mj-section or mj-wrapper.
<mj-mosaico-block-begin name="Artcile Block" postrender="myfeature" />
<mj-section>
...
</mj-section>
<mj-mosaico-block-end />name(required) - must be unique and should end withBlockpostrender(optional) - custom postrender functions, seetemplate/demo/postrender.js.
mj-mosaico-text is a self closing 'decorator' tag and has to be placed right before mj-text.
<mj-column>
<mj-mosaico-text name="Body Text" visible="true" />
<mj-text>Lorem Ipsum</mj-text>
</mj-column>For single-line text fields with and no WYSIWYG editor add a <span> tag:
<mj-column>
<mj-mosaico-text name="Title Text" visible="true" />
<mj-text><span>Title</span></mj-text>
</mj-column>name(required) - should end withTextvisible(optional) - if present, enables a toggle switch and sets the default state. Acceptstrueorfalse.
mj-mosaico-button is a self closing 'decorator' tag and has to be placed right before mj-button.
<mj-column>
<mj-mosaico-button name="Button" visible="true" />
<mj-button href="#">Click Me</mj-button>
</mj-column>name(required) - should end withButtonvisible(optional) - if present, enables a toggle switch and sets the default state. Acceptstrueorfalse.
mj-mosaico-image is a self closing 'decorator' tag and has to be placed right before mj-image.
<mj-column>
<mj-mosaico-image name="Image" visible="true" placeholder-height="200" show-placeholder="true"/>
<mj-image src="images/550x200.png" />
</mj-column>name(required) - should end withImageplaceholder-height(required) - placeholder height (px)show-placeholder(optional) - iftrue, Mosaico will show themj-imageas placeholdervisible(optional) - if present, enables a toggle switch and sets the default state. Acceptstrueorfalse.
There're some extra divs left behind when exporting HTML in Mosaico, which shouldn't cause any rendering issues. In case you're using Mosaico with Mailtrain, add this custom script to your Mailtrain installation: public/mosaico/custom/mjml-mosaico-export-postrender.js. Then adjust your Mailtrain config:
[mosaico]
customscripts=["/mosaico/custom/mjml-mosaico-export-postrender.js"]
Contributions are welcome from everyone.
GPL-V3.0