23 lines
477 B
Python
23 lines
477 B
Python
|
#!/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
|