Skip to main content

Python implementation for MJML - a framework that makes responsive-email easy

Project description

mjml-stub

This is an unofficial Python port of mjml - a markup language created by Mailjet and designed to reduce the pain of coding a responsive email.

WARNING: stub implementation only!

This library only implements a subset of the original MJML project. It lacks several features found in the JavaScript mjml implementation (e.g. minification, beautification and validation). Also the code likely contains many additional bugs.

The upside is that there are lot of possibilities for you to make a real difference when you improve the code :-)

Goals / Motivation

This library should track the JS version of mjml closely so ideally you should get the same HTML. However even under the best circumstances this library will always lag a bit behind as each changes must be translated to Python manually (a mostly mechanical process).

While I like the idea behind mjml and all the knowledge about the quirks to get acceptable HTML rendering by various email clients we did not want to deploy a Node.js-based stack on our production servers. We did not feel comfortable auditing all 220 JS packages which are installed by npm install mjml (and re-doing this whenever new versions are available). Also due to data-privacy concerns we were unable to use any third-party products (i.e. MJML's API offering).

After a short spike to check the viability of a Python implementation I went ahead and wrote enough code to ensure some existing messages could be converted to mjml. Currently the library is deployed in some light production scenarios.

Another benefit of using Python is that we can integrate that in our web apps more closely. Also the startup overhead of CPython is much lower than Node.js so we can also generate a few mails via CLI applications without massive performance problems. CPython uses ~70ms to translate a trivial mjml template to HTML while Node.JS needs ~650ms.

Documentation

The idea is to implement the mjml XML dialect exactly like the JS implementation so eventually you should be able to use the official docs and other online resources found on mjml.io. However we are nowhere near that right now! The current code can render the "Hello World" example as well as images, tables and groups but many components remain to be reimplemented. I'd love to see your pull requests to improve the current state though.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mjml-0.5.3.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

mjml-0.5.3-py3-none-any.whl (35.5 kB view details)

Uploaded Python 3

File details

Details for the file mjml-0.5.3.tar.gz.

File metadata

  • Download URL: mjml-0.5.3.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for mjml-0.5.3.tar.gz
Algorithm Hash digest
SHA256 7d357cbc9259241d28b81c059bbb1daaa456bbd15704d103ac57bc67a554c943
MD5 6b4e855a8cf2a6ff5c7d694f8d827a32
BLAKE2b-256 b4273f62fccb974ca299b08495da436c6e82198229c9b16ab82a75e80638bf75

See more details on using hashes here.

File details

Details for the file mjml-0.5.3-py3-none-any.whl.

File metadata

  • Download URL: mjml-0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 35.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for mjml-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 04e81ecf4d76c6ad456da5ae0b48a72eb4849acd843a50c0c8ba02d74f7dd91e
MD5 ba393f055cf3e2e162eafb11df9e1283
BLAKE2b-256 65fa9264c5050b4eaed34500b4b94771f7bb91b80588c2bc607f8ba7fcee77bd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page