Skip to content

Commit

Permalink
Use cache folder inside cache/
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Dec 18, 2015
1 parent fc99b38 commit ec5fc6b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions nikola/plugins/template/jinja.py
Expand Up @@ -52,21 +52,21 @@ def __init__(self):
"""Initialize Jinja2 environment with extended set of filters."""
if jinja2 is None:
return
# Not ideal because it's not using our cache structure
# but we don't have that folder at init time
cache = jinja2.FileSystemBytecodeCache()

def set_directories(self, directories, cache_folder):
"""Create a new template lookup with set directories."""
if jinja2 is None:
req_missing(['jinja2'], 'use this theme')
cache_folder = os.path.join(cache_folder, 'jinja')
makedirs(cache_folder)
cache = jinja2.FileSystemBytecodeCache(cache_folder)
self.lookup = jinja2.Environment(bytecode_cache=cache)
self.lookup.trim_blocks = True
self.lookup.lstrip_blocks = True
self.lookup.filters['tojson'] = json.dumps
self.lookup.globals['enumerate'] = enumerate
self.lookup.globals['isinstance'] = isinstance
self.lookup.globals['tuple'] = tuple

def set_directories(self, directories, cache_folder):
"""Create a new template lookup with set directories."""
if jinja2 is None:
req_missing(['jinja2'], 'use this theme')
self.directories = directories
self.create_lookup()

Expand Down

0 comments on commit ec5fc6b

Please sign in to comment.