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>
<mj-text font-size="20px" color="#F45E43" font-family="helvetica">Hello World</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
''')
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,
)
Development
python -m venv env
. env/bin/activate
pip install -r requirements.txt
maturin develop
Sponsor
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
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
Close
Hashes for mjml_python-1.0.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 986a4e75b576ecec0e3c2c7bfb7cbc45c078753565a577b99558c01966ca0e15 |
|
MD5 | 7f3f3f743b99d3fd22ab99799ce33897 |
|
BLAKE2b-256 | 1c80b046c9b05b6defcd81499914745c409b7681d1c35c1d1390d12c55ff921d |
Close
Hashes for mjml_python-1.0.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78aa2beac4efd71f8e12779f31ed847815e0a74addac4441622ef91f1d885338 |
|
MD5 | cfa62f92bf677939d4ca362462aafc89 |
|
BLAKE2b-256 | 71c656670547d548f9bafcad14e4f99bfd2ce1bbc58b953c12cf455e1a41718e |
Close
Hashes for mjml_python-1.0.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 371627e0463d259ae47ae7825f65fa22a5a6ce843ea67bd896442587152a9d9c |
|
MD5 | 13bb45e0eb99aa09224ffcb4459b871f |
|
BLAKE2b-256 | 5590b90ba2c43fbd1f47bf915ea0a08eaf3e2c10a02bb5e4dabce578bd5f95db |
Close
Hashes for mjml_python-1.0.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7cfe3842474d7cbe2cced674cef377c43b8cd6676fa4159f8e0bcedfcf1553a |
|
MD5 | e8c32b3d53cd220b994df05dab74d034 |
|
BLAKE2b-256 | 8789f4801d4470989f7b16843c3c1a20a776bb0f9bb5c146dc82ae4b860844dd |
Close
Hashes for mjml_python-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1f014e02469108d5b19695ce2a980190d34ac5e13b0ddc3b9e2c54a316016ef |
|
MD5 | 563106c103d3ac84a019a956ae9e0afa |
|
BLAKE2b-256 | 7bec5b11b03674cf9fa2efec8aaa776677ab55d4f531f005edea15a872d5c844 |
Close
Hashes for mjml_python-1.0.0-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4d25bbe1dba67fb0f0f46e8e0dec8b2c460895d5ae3438b0ef84b691dd22816 |
|
MD5 | 87f5086fd8861443fa4549c90fffaf88 |
|
BLAKE2b-256 | 95d5b2fee2d2b2eba7996c0f0c3a465fafbdf96ae9bee2f6bf9a61a90bd45eb9 |
Close
Hashes for mjml_python-1.0.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f31ccd08dc80b804f4cfe55843283c6b4b332e863c34ea5261a4431242dfa7ff |
|
MD5 | 72aeaa478883b4ada68ac4c9f074bf98 |
|
BLAKE2b-256 | 7831359789afd4966abd09d30272b3a69313f53fbad668814b3e860fceed78da |
Close
Hashes for mjml_python-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bee9e3bd01ab8949e242b565116d964d612a9f6ca65d0f32c8522ed9f72de710 |
|
MD5 | 56af783e263b6917779a89cbe9146935 |
|
BLAKE2b-256 | 5f3873e708a97a236ee805a5b94caaa915ba85d7c197d97253e752fcd57a957c |
Close
Hashes for mjml_python-1.0.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30f1f4530ea968ab3924d3bca1cedcf1e2b044ff19d3e226aff940ab7b9ed176 |
|
MD5 | a51928b25bb156324905633d0f4cb57c |
|
BLAKE2b-256 | a849728de8acce1193f89a9af6777e62b987edb851809a2228add86f215dcc6c |
Close
Hashes for mjml_python-1.0.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b96b2e7b36053ebd1ee9c8134fe9e87b03fb3dd8ce16ca52aaba2d49b73dfb6c |
|
MD5 | a67b71545b420c422c706757ac97ac4f |
|
BLAKE2b-256 | fb1c14247df1be1d84352cf74e11db8e187e42126f5f396e42bb3fe8c66ba1f5 |
Close
Hashes for mjml_python-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44baf133271444acbaac0946e7cea474e1a5a825faa9e94c2dcdd363d8ee190c |
|
MD5 | d45400980df2c7fa1cb6e70ddd13ccc8 |
|
BLAKE2b-256 | 2c92ef68aa08a7db4068b923a1dcffff01916897167de0c09403466c2b443baa |
Close
Hashes for mjml_python-1.0.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00fe7bb140260f17135b8be4b424b9e5451f4fb02cf011d143478b974c8ed59c |
|
MD5 | ad8f1c04ba65b1f4748c47902460e342 |
|
BLAKE2b-256 | 91d19a36a3546a9370c7fad2f1345b526c9c98c580f5af2b88734df871127aa4 |
Close
Hashes for mjml_python-1.0.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd2766dbe9d475aefef98814d99e7eff8f84f53dd960310b173a259b40cedbe0 |
|
MD5 | bb71a656f1e27e2067d57d0eaff19fa7 |
|
BLAKE2b-256 | b1df4582febe065da1ef7636a25e32b275aa9cbb83b19017962cdec13e891fbc |
Close
Hashes for mjml_python-1.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c88f0fb9419cac0b04d152d0a3cc1b2ce72a70ecdc4b43d89a13170b3113fed0 |
|
MD5 | 0bf1deb979f821179a829c1494a275c4 |
|
BLAKE2b-256 | 45c0903ef9c5d86f5e808d4da647cfcdb3da46cd9e1259db0ddfa4a4b0dfc3ea |
Close
Hashes for mjml_python-1.0.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 316ff2e48f79d6de48b07b7f5a4511b2f6ce08f4cdbfb1d76b17ecba5f48ab6d |
|
MD5 | 3453e1b6703b9334899e32ef9955a5ad |
|
BLAKE2b-256 | e036d9269b414222572019ca33f611e1e4548b91d66254ca5ba2c7be173306f1 |
Close
Hashes for mjml_python-1.0.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c8499354cd86b96640e0b78577b1c64e7cb1b7b4e1ea58ec6aa27ea0c137e38 |
|
MD5 | 10bca516fef8a1dc4b378e7109f402e3 |
|
BLAKE2b-256 | fccf90f729891b6b5d3faa17937bf40dd465e2e2034bde8e6decf63b0ff4e9ba |
Close
Hashes for mjml_python-1.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c47031ecdc2d9f800584b7751718fc857ededc24ab405777eac652720e698e6b |
|
MD5 | 31d639d2ebf79aadae532bddc725d64b |
|
BLAKE2b-256 | 7519ddac250067c21d558a4091d501bbb24d5661f1e8faa0d46d7a78dafd2e95 |
Close
Hashes for mjml_python-1.0.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 978a4b9ece63ec50bad6aa7a1ce5f3aad162fe9c5f63ea4137b38f73e447d23c |
|
MD5 | e840860cf7e103e3846368799ece0032 |
|
BLAKE2b-256 | 2e87a5a3144de083d6cafe08dfee973c1082a61dd6138411fd9e1197d1b92540 |