A Python wrapper for MRML (Rust port of MJML).
Project description
mjml-python
Compile MJML at runtime without an external Node service/process. It is a Python wrapper for MRML (Rust port of MJML).
Why
From MRML:
A Node.js server rendering an MJML template takes around 20 MB of RAM at startup and 130 MB under stress test. In Rust, less than 1.7 MB at startup and a bit less that 3 MB under stress test. The Rust version can also handle twice as many requests per second.
All of that is without considering http transaction cost when using a node service or process.
How
Install from PyPI:
pip install mjml-python
Import mjml2html
and pass a string to compile:
from mjml import mjml2html
html = mjml2html(
'''
<mjml>
<mj-body>
<mj-section>
<mj-column>
<mj-image width="100px" src="/assets/img/logo-small.png"></mj-image>
<mj-divider border-color="#F45E43"></mj-divider>
<!-- Say hello to the user -->
<mj-text font-size="20px" color="#F45E43" font-family="Open Sans">Hello World</mj-text>
</mj-column>
</mj-section>
<mj-section>
<mj-column>
<mj-social font-size="15px" icon-size="30px" mode="horizontal">
<mj-social-element name="facebook" href="https://mjml.io/">
Facebook
</mj-social-element>
<mj-social-element name="google" href="https://mjml.io/">
Google
</mj-social-element>
<mj-social-element name="twitter" href="https://mjml.io/">
Twitter
</mj-social-element>
</mj-social>
</mj-column>
</mj-section>
</mj-body>
</mjml>
''',
disable_comments=True,
social_icon_origin="https://example.com",
fonts={
"Open Sans": "https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,700",
"Ubuntu": "https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700",
})
Example using Django templates
from django.core.mail import send_mail
from django.template.loader import render_to_string
from mjml import mjml2html
context = {'foo': 'bar'}
text_message = render_to_string('my_text_template.txt', context)
html_message = mjml2html(render_to_string('my_mjml_template.mjml', context))
send_mail(
'Subject here',
text_message,
'from@example.com',
['to@example.com'],
fail_silently=False,
html_message=html_message,
)
Options
mjml-python
supports the following options:
Name | Type | Default value | Comment |
---|---|---|---|
disable_comments |
bool |
False |
Strip comments out of rendered HTML |
social_icon_origin |
str | None |
None |
Custom URL origin for social icons. Icon name is appended (e.g. facebook.png ). |
fonts |
dict[str, str] | None |
None |
Fonts imported in the HTML rendered by MJML. |
Notes :
- When
fonts
option is set toNone
, the following default fonts will be used:{ "Open Sans": "https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,700", "Droid Sans": "https://fonts.googleapis.com/css?family=Droid+Sans:300,400,500,700", "Lato": "https://fonts.googleapis.com/css?family=Lato:300,400,500,700", "Roboto": "https://fonts.googleapis.com/css?family=Roboto:300,400,500,700", "Ubuntu": "https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700", }
Development
python -m venv env
. env/bin/activate
pip install -r requirements.txt
maturin develop
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for mjml_python-1.2.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 810b4425b8449576e611dbb21ca45ab776670eaa30d6e6d0eac5fb489f904fd0 |
|
MD5 | 88f4ae7e1790bab19fbe68785267e00e |
|
BLAKE2b-256 | a6232730a70ee08c76ac1eca4592d4c0b11ed2f958cc120391f367b714e2c4c3 |
Hashes for mjml_python-1.2.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cfe8d5df4073662a2b4a47391aa6348fe7647e70befe75d8fdbc7061e8bdedd |
|
MD5 | 1e25a5a6022d2ea433bb29cedf5400c9 |
|
BLAKE2b-256 | c681fb3d779a1fc2ad38e3f836e6093d65cec5039e81e7e9f50e9d675350f940 |
Hashes for mjml_python-1.2.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75900ab992704e6cceabf1bc704dcfd8eb07ab84348ce0ab6cdc767f27f1ef76 |
|
MD5 | df5bd2476ff378569cb8262325f49cae |
|
BLAKE2b-256 | 6180f26ef7a8018ee5947d9c0d63ef35ea9a68b6220794312865424c473dbeef |
Hashes for mjml_python-1.2.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a817a2f4b31ca4fc9f9f7d6a18db5d4bae3c642eff0a424bdb6296241203f22e |
|
MD5 | a69b29a9e39f17aa4be483fca5ce2c22 |
|
BLAKE2b-256 | fdb56f0e9efbcc3513a9ba362c859cebb69628cbf4757f0ad759926c87ce89d5 |
Hashes for mjml_python-1.2.2-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5aa154e72e6092a3af3e507acb7143641c28a2c075dffae39ac341cbeb86e54c |
|
MD5 | c4af7b4ff8a123f19efff82bacb2e49f |
|
BLAKE2b-256 | 115bce13eade845cee15a92f8c8529f13c9e62405ac715d4e355190d414ca9da |
Hashes for mjml_python-1.2.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbd32e054ab8dd67c945bee9e698f6d9c112748c86304669ca0bd92462d045b9 |
|
MD5 | 001788b2e4da1ef3d817abe7481d3392 |
|
BLAKE2b-256 | 7d73983d8ae70ea0ac340110797710d24c39c56b3fab09f5dfd0776d33b65b48 |
Hashes for mjml_python-1.2.2-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0843a23c593602667af9692361784dce8d8fca0a22e84cbc90ffdb52646332e6 |
|
MD5 | 663685dd2bfe23e0283e227120ba818e |
|
BLAKE2b-256 | 507064fe593470be0a0e06087291655907f93ca2d10c9959e3e219ae1475ec7b |
Hashes for mjml_python-1.2.2-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef2ed59db2889b49131021c532f5bc77d4c45479ac72367a59b0b234d6a0764e |
|
MD5 | e2d4e2d1b082415f47c43bbed80f8fde |
|
BLAKE2b-256 | 258a255a2113771f682be4e9335006fcb2947713c0198349b890893ef12506de |
Hashes for mjml_python-1.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d5cea0ae6ea90898ae0e32ddb5dfc4e69d847cc758c499d4ae4ba103e26ba35 |
|
MD5 | 011126f2ef7d82389c2b1fbfbaa75c82 |
|
BLAKE2b-256 | f7989bfd511b6ec0bc7d2cf82cc2bc11980841cf5a14be7483bd01edf41c8754 |
Hashes for mjml_python-1.2.2-cp312-cp312-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e936113ef6c895ad6dacf8a94b9d27fb5d62ec3990d7e235b37b26a4c05a6555 |
|
MD5 | a83d5d747c202e543e164e6082450d03 |
|
BLAKE2b-256 | d9a717926a185238571effcaedfe8c7e395f09cae4f2e79ef8537ef8d84ff989 |
Hashes for mjml_python-1.2.2-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0228d5cb19f5fc062da272d63eff78460616a6e068c1a086ff09b2d77322d149 |
|
MD5 | 9102c909fa365273027753eba23bd705 |
|
BLAKE2b-256 | ce5179f624d249ae7e83be887dce7e2a763bd51fb299b4e0c682ea7e88d2ac52 |
Hashes for mjml_python-1.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b350beeff8f42813796fde2c0e420a55c7476407b6f4d489e6e9312f22286c90 |
|
MD5 | 84fa0aa9c93643df227a720289394c9e |
|
BLAKE2b-256 | bbb52d148f4998b41de8e2738e61c9affc3198c0d9fd422d509f9dc13fdfbc66 |
Hashes for mjml_python-1.2.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc45a5c570a5e0f7219f4003974b272cc7b7b6ad50c1e161f391cec9386d5322 |
|
MD5 | fec34e8212ae891dec3aa9d7f92ba646 |
|
BLAKE2b-256 | 8be43fa874df65d2ba8cc6d20b5fff6cc9d0df7852f0cf44ac9f118f25117959 |
Hashes for mjml_python-1.2.2-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91c5608f23c7e9ebea2b7f742d8c5a2f0ce680ad93ed72051af1ec5b1fc924a9 |
|
MD5 | 61c53d44e545d66a28c4ca8b844ad6df |
|
BLAKE2b-256 | ea93991eded8c750b0c6027654caa36affbe030cca45c3e84f314347e57479a5 |
Hashes for mjml_python-1.2.2-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88f4c5b387202808cb3bdd90f4bfa9036af4e10cbaa57efbc764976e1efaa99d |
|
MD5 | 25bc0ecbe24b624056912184c0265292 |
|
BLAKE2b-256 | 058d7fbf7c13cdb8096f604e441ba011f1583c3b365f84bd33814da5b1072fff |
Hashes for mjml_python-1.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3281d98517dd7c9e875813e91c94c7e75fc6785d1807882e26eb64df33368778 |
|
MD5 | 34d0f2220152c578e865aaba8ce18b34 |
|
BLAKE2b-256 | 4523f24dde91fadd24ce4b72c24ac2cc8ffd1d8d5a53d3a6d61aed9586b852ef |
Hashes for mjml_python-1.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61acb161fbbbffbe62b7693195f3ea829a381dcf3a16dcc0234a363e04177f36 |
|
MD5 | 93e6160fc96e0f89ad14da885b83de7a |
|
BLAKE2b-256 | de35ca323b8ffe8dacf6db7cd6e1e9cd52a594d5d1534afc86c8e87037fe0b70 |
Hashes for mjml_python-1.2.2-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc2f2c891d0e56988689575b623bd518dc360b50d2312cdd5357a617a812d6f9 |
|
MD5 | 7b4e5e11c9040e44cc38b28eabef68a3 |
|
BLAKE2b-256 | f941f101ab13821d3ebd6e47cb912fe882a4ca9560313d7946f9411886f7fe0b |
Hashes for mjml_python-1.2.2-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff7bdc7009f1cc0095e3669f090ca07aa502ebe06852e246ae8c80ea3014680d |
|
MD5 | 3ad04b6507004feadaec1abdc2aab401 |
|
BLAKE2b-256 | 9cedc47bf8212214b96c084833ff23828655cb5a451105a107180eefb9e0f636 |
Hashes for mjml_python-1.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df9e74910bdc148af9915ec8ea31bd5addd49501a35d28adc6e0bbe2711feae8 |
|
MD5 | bc15392e6079d7747bfc2ca6bf6f1796 |
|
BLAKE2b-256 | f0e1a515a88f9a349ce954ce2c2fdce1f54ee3b2edb3d5625857d4b1bd950cf6 |
Hashes for mjml_python-1.2.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81a6a66a44967b935330df429a634cb1adef302e13a473c1aee5ab0656da75a3 |
|
MD5 | 94982e15b2a5caef34c619b552127707 |
|
BLAKE2b-256 | e55e16f71be3045b6c567df56feee983a7c433632827a4dd8ae08455cdf37856 |
Hashes for mjml_python-1.2.2-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7655782852f72ba54be3155a17ff655affe7baf9e063f9e80608ed173419c3b |
|
MD5 | 1ae4c1eda800a6c6d68b51fc5afe8a5f |
|
BLAKE2b-256 | 32cbf1a1ee49222a67a30926827fd45e10eb3f0f342f6273f1aaa13009c393f1 |
Hashes for mjml_python-1.2.2-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cb1a4fbf31aea2c681aef595159c6eb1f531caaac38efb8f975bd9b34747750 |
|
MD5 | fb79bf3d7b141c41b2cc3c2fae152cca |
|
BLAKE2b-256 | 3bc48d36ec789a328f095ea8ca9acb6dd0e15b5bfd9d07a083bb4c0f9712016a |
Hashes for mjml_python-1.2.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45c45f784ab32b7a44fc3600bfe992ab15d9209fe143753aaa5f764ba2fb8e7f |
|
MD5 | ef846ab7419a9f9cb8d415db43d548b2 |
|
BLAKE2b-256 | 6b290077b51b4d17b79dd8dfc62ca43e87fcf219a8f19b1f7c5f408ecf44ebe7 |
Hashes for mjml_python-1.2.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43031b0e3aa4816e43c747ad0d1662a69f676a8b22db578d8f81ef5886982dc1 |
|
MD5 | c9d39f222738c298e2373362f89c2c67 |
|
BLAKE2b-256 | ab957e4697244cfb112295452a288fd54a7814dee2bea866d1e6d0ee81998f86 |
Hashes for mjml_python-1.2.2-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb8199eecd739188498b0068737f9870409ad74f7a851b216e4d55481bc6246e |
|
MD5 | 7a17f2a567990f7bb31191d00731ad9a |
|
BLAKE2b-256 | 78f7496f67e7fa8af84c0627b6a983416be33df11b2bd16228f0ea4ff7d004c1 |
Hashes for mjml_python-1.2.2-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cbdbae32fdcfb8ed419c802ed8dcd6e45c23871bc31eb9985780c74b487e3b5 |
|
MD5 | 94bc4214883cb5d58c758aaf86734ab6 |
|
BLAKE2b-256 | 9cc79b9f9dc1aa003712982322be141b14a63caafa3bd406a8d0b9aa7e905124 |
Hashes for mjml_python-1.2.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2fdab9c30ca771e45f6f1a7021f8d69065f2d5c4b25ad89308438b831252faa |
|
MD5 | 3226a02e88c198bd1872f65fde9bc255 |
|
BLAKE2b-256 | d532a1bd82cb68b3b11938b6c20242f1425d89b20e8af73852bf35c9152f313f |
Hashes for mjml_python-1.2.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17f61a154922629ebb3a8992e5bfad0a25d0a3fd0df25f554571b973c06ccebc |
|
MD5 | c2e29f447d00949a0159157fb15da9d3 |
|
BLAKE2b-256 | bc8f179391d6b089aadfcecfe9d761becf2e94832213d3a0ac274b3df5b799f4 |
Hashes for mjml_python-1.2.2-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03f2bf0847fdd7b70283d3db6ac5bfebbfb38ef571fdaa22c0036b5dc519a3b6 |
|
MD5 | 201ceda9c4bee0a5ab6dd9a4c9e15ac9 |
|
BLAKE2b-256 | 12181166c196befa8d1e9f43e60fddf4a5dde0e527a24240eee71dc49816847c |