Some basic MJML Components to generate Mosaico Templates. Use at your own risk.
-
Clone the repo
-
npm install
inside -
Copy
templates/demo
totemplates/name
-
Edit
templates/name/index.mjml
-
gulp build --tmpl name
to build the template -
When using Mailtrain, copy
templates/name
tomailtrain/public/mosaico/templates/name
and enable the template in yourconfig
file. -
When using any other Mosaico build, rename
templates/name/index.html
totemplates/name/template-name.html
and 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 withBlock
postrender
(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 withText
visible
(optional) - if present, enables a toggle switch and sets the default state. Acceptstrue
orfalse
.
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 withButton
visible
(optional) - if present, enables a toggle switch and sets the default state. Acceptstrue
orfalse
.
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 withImage
placeholder-height
(required) - placeholder height (px)show-placeholder
(optional) - iftrue
, Mosaico will show themj-image
as placeholdervisible
(optional) - if present, enables a toggle switch and sets the default state. Acceptstrue
orfalse
.
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