.. image:: https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg
:target: https://stand-with-ukraine.pp.ua
:alt: Stand With Ukraine
|
.. image:: https://github.com/liminspace/django-mjml/actions/workflows/test.yml/badge.svg?branch=main
:target: https://github.com/liminspace/django-mjml/actions/workflows/test.yml
:alt: test
.. image:: https://img.shields.io/pypi/v/django-mjml.svg
:target: https://pypi.org/project/django-mjml/
:alt: pypi
|
.. image:: https://cloud.githubusercontent.com/assets/5173158/14615647/5fc03bf8-05af-11e6-8cdd-f87bf432c4a2.png
:target: #
:alt: Django + MJML
django-mjml
===========
The simplest way to use `MJML <https://mjml.io/>`_ in `Django <https://www.djangoproject.com/>`_ templates.
|
Installation
------------
Requirements:
^^^^^^^^^^^^^
* ``Django`` from 2.2 to 5.1
* ``requests`` from 2.24.0 (only if you are going to use API HTTP-server for rendering)
* ``mjml`` from 4.7.1 to 4.15.2 (older version may work, but not tested anymore)
**\1\. Install** ``mjml``.
Follow https://github.com/mjmlio/mjml#installation and https://documentation.mjml.io/#installation to get more info.
**\2\. Install** ``django-mjml``. ::
$ pip install django-mjml
If you want to use API HTTP-server you also need ``requests`` (at least version 2.24)::
$ pip install django-mjml[requests]
To install development version use ``git+https://github.com/liminspace/django-mjml.git@main`` instead ``django-mjml``.
**\3\. Set up** ``settings.py`` **in your django project.** ::
INSTALLED_APPS = (
...,
'mjml',
)
|
Usage
-----
Load ``mjml`` in your django template and use ``mjml`` tag that will compile MJML to HTML::
{% load mjml %}
{% mjml %}
<mjml>
<mj-body>
<mj-section>
<mj-column>
<mj-text>Hello world!</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
{% endmjml %}
|
Advanced settings
-----------------
There are three backend modes for compiling: ``cmd``, ``tcpserver`` and ``httpserver``.
cmd mode
^^^^^^^^
This mode is very simple, slow and used by default.
Configure your Django::
MJML_BACKEND_MODE = 'cmd'
MJML_EXEC_CMD = 'mjml'
You can change ``MJML_EXEC_CMD`` and set path to executable ``mjml`` file, for example::
MJML_EXEC_CMD = '/home/user/node_modules/.bin/mjml'
Also you can pass addition cmd arguments, for example::
MJML_EXEC_CMD = ['node_modules/.bin/mjml', '--config.minify', 'true', '--config.validationLevel', 'strict']
Once you have a working installation, you can skip the sanity check on startup to speed things up::
MJML_CHECK_CMD_ON_STARTUP = False
tcpserver mode
^^^^^^^^^^^^^^
This mode is faster than ``cmd`` but it needs the `MJML TCP-Server <https://github.com/liminspace/mjml-tcpserver>`_.
Configure your Django::
MJML_BACKEND_MODE = 'tcpserver'
MJML_TCPSERVERS = [
('127.0.0.1', 28101), # the host and port of MJML TCP-Server
]
You can set several servers and a random one will be used::
MJML_TCPSERVERS = [
('127.0.0.1', 28101),
('127.0.0.1', 28102),
('127.0.0.1', 28103),
]
httpserver mode
^^^^^^^^^^^^^^^
don't forget to install ``requests`` to use this mode.
This mode is faster than ``cmd`` and a bit slower than ``tcpserver``, but you can use official MJML API https://mjml.io/api
or run your own HTTP-server (for example https://github.com/danihodovic/mjml-server) to render templates.
Configure your Django::
MJML_BACKEND_MODE = 'httpserver'
MJML_HTTPSERVERS = [
{
'URL': 'https://api.mjml.io/v1/render', # official MJML API
'HTTP_AUTH': ('<Application ID>', '<Secret Key>'),
},
{
'URL': 'http://127.0.0.1:38101/v1/render', # your own HTTP-server
},
]
You can set one or more servers and a random one will be used.
Raw data
{
"_id": null,
"home_page": "https://github.com/liminspace/django-mjml",
"name": "django-mjml",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "django, mjml, django-mjml, email, layout, template, templatetag",
"author": "Igor Melnyk @liminspace",
"author_email": "liminspace@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/b1/09/d4f32601d32579b521d89e3ceeadb9cce711b8b0d1b782f61b4c411b681a/django_mjml-1.3.tar.gz",
"platform": "OS Independent",
"description": ".. image:: https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg\n :target: https://stand-with-ukraine.pp.ua\n :alt: Stand With Ukraine\n\n|\n\n.. image:: https://github.com/liminspace/django-mjml/actions/workflows/test.yml/badge.svg?branch=main\n :target: https://github.com/liminspace/django-mjml/actions/workflows/test.yml\n :alt: test\n\n.. image:: https://img.shields.io/pypi/v/django-mjml.svg\n :target: https://pypi.org/project/django-mjml/\n :alt: pypi\n\n|\n\n.. image:: https://cloud.githubusercontent.com/assets/5173158/14615647/5fc03bf8-05af-11e6-8cdd-f87bf432c4a2.png\n :target: #\n :alt: Django + MJML\n\ndjango-mjml\n===========\n\nThe simplest way to use `MJML <https://mjml.io/>`_ in `Django <https://www.djangoproject.com/>`_ templates.\n\n|\n\nInstallation\n------------\n\nRequirements:\n^^^^^^^^^^^^^\n\n* ``Django`` from 2.2 to 5.1\n* ``requests`` from 2.24.0 (only if you are going to use API HTTP-server for rendering)\n* ``mjml`` from 4.7.1 to 4.15.2 (older version may work, but not tested anymore)\n\n**\\1\\. Install** ``mjml``.\n\nFollow https://github.com/mjmlio/mjml#installation and https://documentation.mjml.io/#installation to get more info.\n\n**\\2\\. Install** ``django-mjml``. ::\n\n $ pip install django-mjml\n\nIf you want to use API HTTP-server you also need ``requests`` (at least version 2.24)::\n\n $ pip install django-mjml[requests]\n\nTo install development version use ``git+https://github.com/liminspace/django-mjml.git@main`` instead ``django-mjml``.\n\n**\\3\\. Set up** ``settings.py`` **in your django project.** ::\n\n INSTALLED_APPS = (\n ...,\n 'mjml',\n )\n\n|\n\nUsage\n-----\n\nLoad ``mjml`` in your django template and use ``mjml`` tag that will compile MJML to HTML::\n\n {% load mjml %}\n\n {% mjml %}\n <mjml>\n <mj-body>\n <mj-section>\n <mj-column>\n <mj-text>Hello world!</mj-text>\n </mj-column>\n </mj-section>\n </mj-body>\n </mjml>\n {% endmjml %}\n\n|\n\nAdvanced settings\n-----------------\n\nThere are three backend modes for compiling: ``cmd``, ``tcpserver`` and ``httpserver``.\n\ncmd mode\n^^^^^^^^\n\nThis mode is very simple, slow and used by default.\n\nConfigure your Django::\n\n MJML_BACKEND_MODE = 'cmd'\n MJML_EXEC_CMD = 'mjml'\n\nYou can change ``MJML_EXEC_CMD`` and set path to executable ``mjml`` file, for example::\n\n MJML_EXEC_CMD = '/home/user/node_modules/.bin/mjml'\n\nAlso you can pass addition cmd arguments, for example::\n\n MJML_EXEC_CMD = ['node_modules/.bin/mjml', '--config.minify', 'true', '--config.validationLevel', 'strict']\n\nOnce you have a working installation, you can skip the sanity check on startup to speed things up::\n\n MJML_CHECK_CMD_ON_STARTUP = False\n\ntcpserver mode\n^^^^^^^^^^^^^^\n\nThis mode is faster than ``cmd`` but it needs the `MJML TCP-Server <https://github.com/liminspace/mjml-tcpserver>`_.\n\nConfigure your Django::\n\n MJML_BACKEND_MODE = 'tcpserver'\n MJML_TCPSERVERS = [\n ('127.0.0.1', 28101), # the host and port of MJML TCP-Server\n ]\n\nYou can set several servers and a random one will be used::\n\n MJML_TCPSERVERS = [\n ('127.0.0.1', 28101),\n ('127.0.0.1', 28102),\n ('127.0.0.1', 28103),\n ]\n\nhttpserver mode\n^^^^^^^^^^^^^^^\n\n don't forget to install ``requests`` to use this mode.\n\nThis mode is faster than ``cmd`` and a bit slower than ``tcpserver``, but you can use official MJML API https://mjml.io/api\nor run your own HTTP-server (for example https://github.com/danihodovic/mjml-server) to render templates.\n\nConfigure your Django::\n\n MJML_BACKEND_MODE = 'httpserver'\n MJML_HTTPSERVERS = [\n {\n 'URL': 'https://api.mjml.io/v1/render', # official MJML API\n 'HTTP_AUTH': ('<Application ID>', '<Secret Key>'),\n },\n {\n 'URL': 'http://127.0.0.1:38101/v1/render', # your own HTTP-server\n },\n ]\n\nYou can set one or more servers and a random one will be used.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Use MJML in Django templates",
"version": "1.3",
"project_urls": {
"Homepage": "https://github.com/liminspace/django-mjml"
},
"split_keywords": [
"django",
" mjml",
" django-mjml",
" email",
" layout",
" template",
" templatetag"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9d789ecd1374525f06bda0aaaf8f3bb1b1a24a05e6b3d00d1ef344194dd8c4bd",
"md5": "b378ec6fa02c817c73ec84e7ffe002f7",
"sha256": "a8eb15f32b6a9c497da48bff36e998b61dcf9bca2c44f3d98c7517e9edd06fe6"
},
"downloads": -1,
"filename": "django_mjml-1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b378ec6fa02c817c73ec84e7ffe002f7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 7890,
"upload_time": "2024-08-21T17:53:07",
"upload_time_iso_8601": "2024-08-21T17:53:07.096139Z",
"url": "https://files.pythonhosted.org/packages/9d/78/9ecd1374525f06bda0aaaf8f3bb1b1a24a05e6b3d00d1ef344194dd8c4bd/django_mjml-1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b109d4f32601d32579b521d89e3ceeadb9cce711b8b0d1b782f61b4c411b681a",
"md5": "58fd21d3f4d5dee68f8b56239ece958c",
"sha256": "d6d2f6cf664f2f7d7e42e12dd1587a45545a7f43393b8dc1a574382975150516"
},
"downloads": -1,
"filename": "django_mjml-1.3.tar.gz",
"has_sig": false,
"md5_digest": "58fd21d3f4d5dee68f8b56239ece958c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 8501,
"upload_time": "2024-08-21T17:53:08",
"upload_time_iso_8601": "2024-08-21T17:53:08.963569Z",
"url": "https://files.pythonhosted.org/packages/b1/09/d4f32601d32579b521d89e3ceeadb9cce711b8b0d1b782f61b4c411b681a/django_mjml-1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-21 17:53:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "liminspace",
"github_project": "django-mjml",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "django-mjml"
}