mjml-python 1.3.5__cp37-abi3-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mjml/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .mjml import *
2
+
3
+ __doc__ = mjml.__doc__
4
+ if hasattr(mjml, "__all__"):
5
+ __all__ = mjml.__all__
mjml/__init__.pyi ADDED
@@ -0,0 +1,27 @@
1
+ from typing import Optional, Dict, Protocol
2
+
3
+
4
+ class IncludeLoader(Protocol):
5
+ def __call__(self, path: str) -> str: ...
6
+
7
+
8
+ def mjml2html(
9
+ input: str,
10
+ *,
11
+ disable_comments: bool = False,
12
+ social_icon_origin: Optional[str] = None,
13
+ fonts: Optional[Dict[str, str]] = None,
14
+ include_loader: Optional[IncludeLoader] = None,
15
+ ) -> str:
16
+ """Convert MJML string to HTML string.
17
+
18
+ Params:
19
+ - input: The input MJML string
20
+ - disable_comments: Strip comments out of rendered HTML
21
+ - social_icon_origin: Custom URL origin for social icons. Icon name is appended
22
+ (e.g. `facebook.png`).
23
+ - fonts: Fonts imported in the HTML rendered by MJML.
24
+ - include_loader: Fetch the included template using the path attribute.
25
+
26
+ Returns: the rendered HTML string.
27
+ """
mjml/mjml.abi3.so ADDED
Binary file
mjml/py.typed ADDED
File without changes
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: mjml-python
3
+ Version: 1.3.5
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ License-File: LICENSE
9
+ Summary: A Python wrapper for MRML (Rust port of MJML).
10
+ Requires-Python: >=3.7
11
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
12
+ Project-URL: Homepage, https://github.com/mgd020/mjml-python
13
+ Project-URL: Bug Tracker, https://github.com/mgd020/mjml-python/issues
14
+
15
+ # mjml-python
16
+
17
+ Compile MJML at runtime without an external Node service/process. It is a Python wrapper for [MRML](https://github.com/jdrouet/mrml) (Rust port of [MJML](https://github.com/mjmlio/mjml)).
18
+
19
+ ## Why
20
+
21
+ From [MRML](https://github.com/jolimail/mrml#why):
22
+
23
+ > 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.
24
+
25
+ All of that is without considering http transaction cost when using a node service or process.
26
+
27
+ ## How
28
+
29
+ Install from [PyPI](https://pypi.org/project/mjml-python/):
30
+
31
+ ```sh
32
+ pip install mjml-python
33
+ ```
34
+
35
+ Import `mjml2html` and pass a string to compile:
36
+
37
+ ```py
38
+ from mjml import mjml2html
39
+
40
+ html = mjml2html(
41
+ '''
42
+ <mjml>
43
+ <mj-body>
44
+ <mj-section>
45
+ <mj-column>
46
+ <mj-image width="100px" src="/assets/img/logo-small.png"></mj-image>
47
+ <mj-divider border-color="#F45E43"></mj-divider>
48
+ <!-- Say hello to the user -->
49
+ <mj-text font-size="20px" color="#F45E43" font-family="Open Sans">Hello World</mj-text>
50
+ </mj-column>
51
+ </mj-section>
52
+ <mj-section>
53
+ <mj-column>
54
+ <mj-social font-size="15px" icon-size="30px" mode="horizontal">
55
+ <mj-social-element name="facebook" href="https://mjml.io/">
56
+ Facebook
57
+ </mj-social-element>
58
+ <mj-social-element name="google" href="https://mjml.io/">
59
+ Google
60
+ </mj-social-element>
61
+ <mj-social-element name="twitter" href="https://mjml.io/">
62
+ Twitter
63
+ </mj-social-element>
64
+ </mj-social>
65
+ </mj-column>
66
+ </mj-section>
67
+ </mj-body>
68
+ </mjml>
69
+ ''',
70
+ disable_comments=True,
71
+ social_icon_origin="https://example.com",
72
+ fonts={
73
+ "Open Sans": "https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,700",
74
+ "Ubuntu": "https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700",
75
+ })
76
+ ```
77
+
78
+ **Example using Django templates**
79
+
80
+ ```py
81
+ from django.core.mail import send_mail
82
+ from django.template.loader import render_to_string
83
+ from mjml import mjml2html
84
+
85
+ context = {'foo': 'bar'}
86
+ text_message = render_to_string('my_text_template.txt', context)
87
+ html_message = mjml2html(render_to_string('my_mjml_template.mjml', context))
88
+ send_mail(
89
+ 'Subject here',
90
+ text_message,
91
+ 'from@example.com',
92
+ ['to@example.com'],
93
+ fail_silently=False,
94
+ html_message=html_message,
95
+ )
96
+ ```
97
+
98
+ **Options**
99
+
100
+ `mjml-python` supports the following options:
101
+
102
+ | Name | Type | Default value | Comment |
103
+ |----------------------|--------------------------------|---------------|----------------------------------------------------------------------------------|
104
+ | `disable_comments` | `bool` | `False` | Strip comments out of rendered HTML |
105
+ | `social_icon_origin` | `str \| None` | `None` | Custom URL origin for social icons. Icon name is appended (e.g. `facebook.png`). |
106
+ | `fonts` | `dict[str, str] \| None` | `None` | Fonts imported in the HTML rendered by MJML. |
107
+ | `include_loader` | `Callable[[str], str] \| None` | `None` | Fetch the included template using the path attribute. |
108
+
109
+ *Notes* :
110
+
111
+ - When `fonts` option is set to `None`, the following default fonts will be used:
112
+ ```py
113
+ {
114
+ "Open Sans": "https://fonts.googleapis.com/css?family=Open+Sans:300,400,500,700",
115
+ "Droid Sans": "https://fonts.googleapis.com/css?family=Droid+Sans:300,400,500,700",
116
+ "Lato": "https://fonts.googleapis.com/css?family=Lato:300,400,500,700",
117
+ "Roboto": "https://fonts.googleapis.com/css?family=Roboto:300,400,500,700",
118
+ "Ubuntu": "https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700",
119
+ }
120
+ ```
121
+
122
+ ## Development
123
+
124
+ With [Nix](https://nixos.org/):
125
+
126
+ ```sh
127
+ nix-shell
128
+ ```
129
+
130
+ With Python 3.7+, Rust and Cargo installed:
131
+
132
+ ```sh
133
+ python3 -m venv env
134
+ source env/bin/activate
135
+ pip install -r requirements.txt
136
+ maturin develop
137
+ python -m unittest
138
+ ```
139
+
@@ -0,0 +1,8 @@
1
+ mjml_python-1.3.5.dist-info/METADATA,sha256=UMeN9fOp5XDPgwKLr8qHMDl9ScE0L9BvWbZdk6NyHNY,4999
2
+ mjml_python-1.3.5.dist-info/WHEEL,sha256=bAwHsP3npahjlk1Z6DF8yvucLuK5k1-aQna2KkymfWs,102
3
+ mjml_python-1.3.5.dist-info/licenses/LICENSE,sha256=DdX4Mk01aGu5kZ8ljtD-ZyL_c5gi6sn_YPvsPRgQVCM,1074
4
+ mjml/__init__.py,sha256=2dJmpc4qHjvXHjqcsnJ6bJgRlD9e7pB4Oqe6RoEzmLQ,99
5
+ mjml/__init__.pyi,sha256=92Fa_ZYPr_nk006nhWaFdrH7Imc2yiG6RZ4BEy51-qc,799
6
+ mjml/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ mjml/mjml.abi3.so,sha256=IUhwWHu8DdDVWp2ZurbHHWDamX88JtxhCE36NCgjVzQ,1522512
8
+ mjml_python-1.3.5.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.8.3)
3
+ Root-Is-Purelib: false
4
+ Tag: cp37-abi3-macosx_11_0_arm64
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 github.com/mgd020
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.