|
@@ -116,6 +116,35 @@ Please see `Jinja documentation <https://jinja.palletsprojects.com/>`_
|
|
|
for more.
|
|
for more.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+Pass Unescaped Content
|
|
|
|
|
+----------------------
|
|
|
|
|
+
|
|
|
|
|
+In case you need to include parts that should not be processed by
|
|
|
|
|
+Jinja, you may pass them using `markupsafe.Markup <https://markupsafe.palletsprojects.com/en/2.1.x/escaping/#markupsafe.Markup>`_:
|
|
|
|
|
+
|
|
|
|
|
+.. code-block:: python
|
|
|
|
|
+
|
|
|
|
|
+ from markupsafe import Markup
|
|
|
|
|
+
|
|
|
|
|
+ email.send(
|
|
|
|
|
+ subject='email subject',
|
|
|
|
|
+ receivers=['first.last@example.com'],
|
|
|
|
|
+ html="""
|
|
|
|
|
+ <h1>Hi,</h1>
|
|
|
|
|
+ <p>{{ raw_content }}</p>
|
|
|
|
|
+ <p>Kind regards
|
|
|
|
|
+ <br>{{ sender.full_name }}</p>
|
|
|
|
|
+ """,
|
|
|
|
|
+ body_params={
|
|
|
|
|
+ 'raw_content': Markup("<strong>this text is passed unescaped as is</strong>")
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+.. warning::
|
|
|
|
|
+
|
|
|
|
|
+ For HTML, content only from trusted sources should be left unescaped.
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
Disabling Jinja
|
|
Disabling Jinja
|
|
|
---------------
|
|
---------------
|
|
|
|
|
|
|
@@ -128,15 +157,20 @@ to render the bodies, you may also disable it:
|
|
|
subject='email subject',
|
|
subject='email subject',
|
|
|
receivers=['first.last@example.com'],
|
|
receivers=['first.last@example.com'],
|
|
|
text="""
|
|
text="""
|
|
|
- Hi,
|
|
|
|
|
- {{ these brackets are not processed }}
|
|
|
|
|
|
|
+ Hi,
|
|
|
|
|
+ {{ these brackets are not processed }}
|
|
|
""",
|
|
""",
|
|
|
html="""
|
|
html="""
|
|
|
- <h1>Hi!</h1>
|
|
|
|
|
- <p>
|
|
|
|
|
- {{ these brackets are not processed }}
|
|
|
|
|
- </p>
|
|
|
|
|
|
|
+ <h1>Hi!</h1>
|
|
|
|
|
+ <p>
|
|
|
|
|
+ {{ these brackets are not processed }}
|
|
|
|
|
+ </p>
|
|
|
""",
|
|
""",
|
|
|
use_jinja=False
|
|
use_jinja=False
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+You may also disable Jinja for all sent emails without passing the argument:
|
|
|
|
|
+
|
|
|
|
|
+.. code-block:: python
|
|
|
|
|
+
|
|
|
|
|
+ email.use_jinja = False
|