32
32
try :
33
33
import jinja2
34
34
from jinja2 import meta
35
+ import pyjade
35
36
except ImportError :
36
- jinja2 = None # NOQA
37
- import pyjade
37
+ pyjade = None # NOQA
38
38
39
39
from nikola .plugin_categories import TemplateSystem
40
40
from nikola .utils import makedirs , req_missing
@@ -49,17 +49,17 @@ class JinjaTemplates(TemplateSystem):
49
49
50
50
def __init__ (self ):
51
51
""" initialize Jinja2 wrapper with extended set of filters"""
52
- if jinja2 is None :
53
- return
52
+ if pyjade is None :
53
+ req_missing ([ 'pyjade' ], 'build this site (compile Jade)' )
54
54
self .lookup = jinja2 .Environment (extensions = ['pyjade.ext.jinja.PyJadeExtension' ])
55
55
self .lookup .filters ['tojson' ] = json .dumps
56
56
self .lookup .filters ['istuple' ] = lambda x : isinstance (x , tuple )
57
57
self .lookup .globals ['enumerate' ] = enumerate
58
58
59
59
def set_directories (self , directories , cache_folder ):
60
60
"""Create a template lookup."""
61
- if jinja2 is None :
62
- req_missing (['jinja2 ' ], 'use this theme' )
61
+ if pyjade is None :
62
+ req_missing (['pyjade ' ], 'use this theme' )
63
63
self .lookup .loader = jinja2 .FileSystemLoader (directories ,
64
64
encoding = 'utf-8' )
65
65
@@ -70,8 +70,8 @@ def set_site(self, site):
70
70
71
71
def render_template (self , template_name , output_name , context ):
72
72
"""Render the template into output_name using context."""
73
- if jinja2 is None :
74
- req_missing (['jinja2 ' ], 'use this theme' )
73
+ if pyjade is None :
74
+ req_missing (['pyjade ' ], 'use this theme' )
75
75
if not template_name .endswith ('.jade' ):
76
76
template_name = os .path .splitext (template_name )[0 ]+ '.jade'
77
77
template = self .lookup .get_template (template_name )
0 commit comments