28 lines
643 B
Python
28 lines
643 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Custom Jinja2 environment.
|
|
"""
|
|
import jinja2
|
|
from django.urls import reverse
|
|
from django.contrib import messages
|
|
from django.utils.timezone import template_localtime
|
|
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,
|
|
'localtime': template_localtime,
|
|
})
|
|
return env
|