26 lines
555 B
Python
26 lines
555 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Custom Jinja2 environment.
|
|
"""
|
|
import jinja2
|
|
from django.urls import reverse
|
|
from django.contrib import messages
|
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
|
|
|
def environment(**options):
|
|
"""
|
|
Custom Jinja2 environment.
|
|
"""
|
|
env = jinja2.Environment(**options)
|
|
env.globals.update({
|
|
'undefined': jinja2.StrictUndefined,
|
|
'autoescape': True,
|
|
'trim_blocks': True,
|
|
'lstrip_blocks': True,
|
|
|
|
'url': reverse,
|
|
'static': staticfiles_storage.url,
|
|
'get_messages': messages.get_messages,
|
|
})
|
|
return env
|