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.1.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef0bc074d2caebeee1f889e44385f127108032ba80abed7335d90803c491d0c0 |
|
MD5 | af835a0b7ac5aea6a03029b629f16db6 |
|
BLAKE2b-256 | 1dc61acf260c8d4285d919a205062ae280319f0d13e72ce74f6135815dbfb013 |
Hashes for mjml_python-1.1.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 223f22ea9e12f6739925438e04b667ade3bdbcb05ecd7d20326b59fb0ce88174 |
|
MD5 | d2e0d225ff72dffe76d00fa1692bccd2 |
|
BLAKE2b-256 | c2eedcd2f655c3273b6afeb0fa0eb47aab0d01e64e88af7ccc64edff4e471477 |
Hashes for mjml_python-1.1.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adc1cc0e156bcdf5d2ec420577f4a910f125583abfd6f7fb5ecfd5860d0b374d |
|
MD5 | d4a5783482d4cd89da718012d2316224 |
|
BLAKE2b-256 | eea095a217b769ee5fb95e61a0f8d3f9b13b8b93d8eb03d22a2bdef8d5870fb2 |
Hashes for mjml_python-1.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f63814a4181f618e4ccfa4aad36a0b4b5e8c0f786450d3e6ef6110c3437afa6b |
|
MD5 | 38afb18f74170172ae6984464cfcd531 |
|
BLAKE2b-256 | 52e17b4c63234b5d18fc6bfa9a2378589f60f5249efde478fba3ae67ad4cd32f |
Hashes for mjml_python-1.1.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24c7a450b352d7e0eadc70f573c6c8a8710c39ae782a565bb5edc23586e9daaa |
|
MD5 | 61ed423628c20bc89d10838f61f7128e |
|
BLAKE2b-256 | 67ffe18c78201d318b3a19b3e90ebe3a920c8554c1391ea2f8a3ce26d98a19aa |
Hashes for mjml_python-1.1.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67231de569c7cd02be73bd7dd89d3e93b6fbd582f7cc40d30d26c804c155d605 |
|
MD5 | 238d19da4796dd9bf939b2af6741d612 |
|
BLAKE2b-256 | 3d17250be856dcf482a0ef7072c5e7710d9bbc4c3b0723a895b9bc6818c72ae3 |
Hashes for mjml_python-1.1.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42bebdd656d73bb40165459195de360eca939b4f65caca1e5699ca2a3b82a803 |
|
MD5 | 9c70859d477ee30d008bb945ca14a05f |
|
BLAKE2b-256 | 26575931ea758f59ccbc20d932f5407885bf81071a0e6ff0eed0dbba73d054d5 |
Hashes for mjml_python-1.1.0-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d40c24f48e7fb6d57a643634dccd9c7757e557f9e90963e8fa614664bb3945c |
|
MD5 | d239adef2bee8dca59f661bb8d8c147e |
|
BLAKE2b-256 | a5e143eb1ed10175239dfc7faa77fcfcb2c2eb74fbf5c96c1e7244d21976e54a |
Hashes for mjml_python-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 287242914ece713c2baced59dd637cebab84827e24f005bcd768f36f6a158055 |
|
MD5 | 2277581d197d205d97ccfc60ab6e4e66 |
|
BLAKE2b-256 | 865652c2305b5fb94784058f8f294721441783ab34080297e69427e46a558e8c |
Hashes for mjml_python-1.1.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8adee6860e816c65addd17d870d0582983098c793e780baf8e2c5a9be4b0dc60 |
|
MD5 | 7a54353ec264bf1c7abe2d262998ad1d |
|
BLAKE2b-256 | e9f1ce3663fcf9f5f7726136ddf64d42e1aa347c4461f9cba498a53e42b62dfc |
Hashes for mjml_python-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d47b47b3a65c7399b4f5b87df91f10063b0a0120b9709e75ff1af1c72ffdd9f0 |
|
MD5 | 983e8b9d1bf4b81db0891a60a2d894d0 |
|
BLAKE2b-256 | 003022e8096db10a21c737c8a2b4430f31f39e2d186b88eb98f558c7212a0174 |
Hashes for mjml_python-1.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b92a281e3b1f5e9c54229693dab872bd6594a7b908d8372b21dd3a721b77210 |
|
MD5 | 5d7cb85411bfa58cc7b842f95335b9c4 |
|
BLAKE2b-256 | d38422504fa19e295a9d34cd2655934737107b7872098c041d11f6ff82cb8550 |
Hashes for mjml_python-1.1.0-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16aff62819bfbcc2720d0265fd64310514fbcff1e84f5c50948b282792a8fe69 |
|
MD5 | 3bf9d0c5c2f07c9935193bec3c8dbeec |
|
BLAKE2b-256 | b940dd8a0008c873621f5c7890a059e4cfca35a7c8bf6274ec1182c0810ccb66 |
Hashes for mjml_python-1.1.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ef08d5ada029e79f2db4bc505ff60989f11eceee2ecba9372958be65e94235e |
|
MD5 | de5c80809c8408648d688ea22a73a332 |
|
BLAKE2b-256 | 6270e62e230234c658a566a56c732c9ba495b35b267814ae6f86c9717c2506a9 |
Hashes for mjml_python-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc53035f481c4500dff56d6a1db93dfca3079bfc404cab6c1a8260531f0efeb8 |
|
MD5 | 294244406620f9fb4310e8000fbeadde |
|
BLAKE2b-256 | 0acdc84cef12f0d9a51de5ba78b9e8b4ddde3c2b6761b691ee05a2545acb5f28 |
Hashes for mjml_python-1.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef0abe43eefe7b1a6dfaa6e5054e141135ed8f6f40c904e7844f60d3a3a74257 |
|
MD5 | 622f8bfa32db8e6a068307b13afa5b64 |
|
BLAKE2b-256 | 201d44da0936401e8ccdd3c45dac4c32cd1dcaed707882a876a472fbf66e3b94 |
Hashes for mjml_python-1.1.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a1d16fac3ff0dba3cf847830c8ce03807c0798e2616927b355a2082c5d3bc32 |
|
MD5 | ea28025e40760e01dc1ebf3245b53f2a |
|
BLAKE2b-256 | dd6b6c0b20d9277f534f359debb8424b8631cc5d29d47a6d482a66d7a8510714 |
Hashes for mjml_python-1.1.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc32aba3f4c369630777975354a25a1c0204d03c92a0107d6b30945c948de5ac |
|
MD5 | b7da4fc22400410a0bf146d5b10b3664 |
|
BLAKE2b-256 | 39a166d98b622377596dc7cb23991300650caa91937b913bd216cd7a4455695f |
Hashes for mjml_python-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55c8006572da443ccc78cedfe9522313f7e5312ba6b9fbc8d94b39cc0c986bab |
|
MD5 | 9c65c7619992e9898cd00fa383255ec5 |
|
BLAKE2b-256 | 1b75e6009e263963622d20cfcc871969756bcd6d5fd5a26438492eb018d06a3e |
Hashes for mjml_python-1.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d218d57d41faa1ea9095b13c797cce414b7561265f0da43614e572639eb78f4 |
|
MD5 | 413b0a5e07c443a5de6ba51f7d3ad29e |
|
BLAKE2b-256 | 8da3c0ea41aae22ab2637505db04f07b5bb63a508c1efde198cbe68505d8e2ec |
Hashes for mjml_python-1.1.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcc462a41d9724db3de47f11702cebb32b7214d1efee28672071d451dbeabb12 |
|
MD5 | a8d8b153ddeab7f8d8583ec3e424f062 |
|
BLAKE2b-256 | 17ae289e5aa876ddfd9ef8be9659cc211b2c24ec09af74e729c5bdbe840cc9ca |
Hashes for mjml_python-1.1.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0a0edaaf5813b0bdf03afcb0cdcde25408cbb09b801415a86f13d1b2bc51e96 |
|
MD5 | 842261f642cc0ee090e6a5bd3004cd5b |
|
BLAKE2b-256 | 25455644b4c8a443fa3d10c66bce2ae070c19a10e192c276d08a65afaf8e2bf7 |
Hashes for mjml_python-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92734a840a50662c4f64ea208320a47189a4ade0b652437e1c1f778a5b96e855 |
|
MD5 | cab7a5c583e79971af28ec14d8a20253 |
|
BLAKE2b-256 | db5d95d5f432fe16627d1ac8ea289ac86a8bafc30e92668b419e01a12618c110 |
Hashes for mjml_python-1.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b57962b564fd5975d98816f34bad3ee3af00de2ec517500a4d3e1ab53c2a4ed |
|
MD5 | 25c37dbc09e5367bc35790840c6abc9b |
|
BLAKE2b-256 | 001a2a01d575a1331e8e951b9c0a125f52063d98b1d1d826fb59b59a0d4fe088 |
Hashes for mjml_python-1.1.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 776a1d77a13c4dcb1ade4213ad5d9075af1d6ff88061e456b19c7812e2023dec |
|
MD5 | af95a6c59d9907bc9d539a341df4f7e0 |
|
BLAKE2b-256 | bf22e3bfc04a70a1b66689377c2bcf030ebc958075a884b3e6dd04a449d661d1 |
Hashes for mjml_python-1.1.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e37e9021ca63ce997c21b5fed5e84743092269a81ca49ae0398d85cda07394db |
|
MD5 | 85ec7c0676c597535a2d74d371a3eca7 |
|
BLAKE2b-256 | eca8cb6af5d6ff9fc8913ecd4714e749ce47363e2631704f111f0935e7fd6f23 |
Hashes for mjml_python-1.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 072cf1c4fd3fd0a890b19de22e40ae447886d005adedd333be2a73bb85e46916 |
|
MD5 | 66df788c211965d0754ad3f19a074791 |
|
BLAKE2b-256 | 68787acdccd5edd8de9e5c5743917d19e7bfc2690924dd63b4ea4d16a6569dea |
Hashes for mjml_python-1.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33df99acb057d5928cdec4fc527ad2dceeb6c74d5a82b3cc64475d849d72898f |
|
MD5 | d964cb0ca33cfe9b286c041cfd92d9be |
|
BLAKE2b-256 | 044f9c6497ce211b1b946f89f6c09227e5006a86954dcb72161842138e31b4f4 |
Hashes for mjml_python-1.1.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a6daad98f846bb244e553d72bd5716771cc8a030028b5d08c0f150e174a090e |
|
MD5 | 976a9810de81f60a2c98bf6cb14f9918 |
|
BLAKE2b-256 | c0964da596d3471db51df885dff5fb028037eadf0ea6ad7b3687ed2a1f76e35a |