-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjinja2.py
35 lines (28 loc) · 1.04 KB
/
jinja2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from django.contrib.staticfiles.storage import staticfiles_storage
from django.urls import reverse
from django.contrib import messages
from jinja2 import Environment
from payroll.utils import format_ballpark_number, format_salary, \
query_transform, format_percentile, url_from_facet, \
param_from_index, format_range, pluralize, an_or_a, \
format_exact_number
def environment(**options):
env = Environment(**options)
env.globals.update({
'static': staticfiles_storage.url,
'url': reverse,
'get_messages': messages.get_messages,
})
env.filters.update({
'format_ballpark_number': format_ballpark_number,
'format_exact_number': format_exact_number,
'format_salary': format_salary,
'query_transform': query_transform,
'format_percentile': format_percentile,
'url_from_facet': url_from_facet,
'param_from_index': param_from_index,
'format_range': format_range,
'pluralize': pluralize,
'an_or_a': an_or_a,
})
return env