Permalink
Browse files

Make jinja2 a runtime error, and only if your theme is using it.

  • Loading branch information...
1 parent b9a6180 commit 6dbdb5717e8185747d0f6301104e632bf90c439b @ralsina committed Dec 28, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −2 nikola/plugins/template_jinja.py
  2. +0 −1 setup.py
View
10 nikola/plugins/template_jinja.py
@@ -25,7 +25,10 @@
"""Jinja template handlers"""
import os
-import jinja2
+try:
+ import jinja2
+except ImportError:
+ jinja2 = None
from nikola.plugin_categories import TemplateSystem
@@ -38,14 +41,17 @@ class JinjaTemplates(TemplateSystem):
def set_directories(self, directories, cache_folder):
"""Createa template lookup."""
+ if jinja2 is None:
+ raise Exception('To use this theme you need to install the "Jinja2" package.')
self.lookup = jinja2.Environment(loader=jinja2.FileSystemLoader(
directories,
encoding='utf-8',
))
def render_template(self, template_name, output_name, context):
"""Render the template into output_name using context."""
-
+ if jinja2 is None:
+ raise Exception('To use this theme you need to install the "Jinja2" package.')
template = self.lookup.get_template(template_name)
output = template.render(**context)
if output_name is not None:
View
1 setup.py
@@ -39,7 +39,6 @@
'yapsy',
'mock>=1.0.0',
'markdown',
- 'Jinja2',
]
if sys.version_info[0] == 2:

0 comments on commit 6dbdb57

Please sign in to comment.