From 9944bb7048458fed0c096a5f77baaa369935cec6 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 23 Feb 2019 17:49:07 +0000 Subject: [PATCH] Graceful error when using Jinja2Templates, but jinja2 is not installed --- starlette/templating.py | 1 + 1 file changed, 1 insertion(+) diff --git a/starlette/templating.py b/starlette/templating.py index 5595364b..488d8c65 100644 --- a/starlette/templating.py +++ b/starlette/templating.py @@ -49,6 +49,7 @@ class Jinja2Templates: """ def __init__(self, directory: str) -> None: + assert jinja2 is not None, "jinja2 must be installed to use Jinja2Templates" self.env = self.get_env(directory) def get_env(self, directory: str) -> "jinja2.Environment":