Titivillus/titivillus/jinja2.py

23 lines
477 B
Python
Raw Normal View History

2018-08-10 08:39:51 -04:00
#!/usr/bin/env python3
"""
Custom Jinja2 environment.
"""
import jinja2
from django.contrib.staticfiles.storage import staticfiles_storage
from django.urls import reverse
def environment(**options):
"""
Custom Jinja2 environment.
"""
env = jinja2.Environment(**options)
env.globals.update({
'static': staticfiles_storage.url,
'url': reverse,
'undefined': jinja2.StrictUndefined,
'autoescape': True,
'trim_blocks': True,
'lstrip_blocks': True,
})
return env