Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ To use HTML transformation features (CSS inlining, image embedding, loading from
.. code-block:: bash

$ pip install emails[html]

To use Jinja2 templates (the ``T()`` shortcut):

.. code-block:: bash

$ pip install emails[jinja]
8 changes: 7 additions & 1 deletion emails/template/jinja_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ def __init__(self, template_text, environment=None):
self.environment = environment
else:
if 'jinja2' not in globals():
globals()['jinja2'] = __import__('jinja2')
try:
globals()['jinja2'] = __import__('jinja2')
except ImportError:
raise ImportError(
"jinja2 is required for template support. "
"Install it with: pip install emails[jinja]"
)
self.environment = jinja2.Environment(**self.DEFAULT_JINJA_ENVIRONMENT)

def compile_template(self):
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def find_version(*file_paths):
install_requires=['python-dateutil', 'puremagic', 'dkimpy'],
extras_require={
'html': ['cssutils', 'lxml', 'chardet', 'requests', 'premailer'],
'jinja': ['jinja2'],
},
zip_safe=False,
classifiers=(
Expand Down
Loading