-
Notifications
You must be signed in to change notification settings - Fork 0
/
wmk_jinja2_extras.py
42 lines (36 loc) · 1.13 KB
/
wmk_jinja2_extras.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
36
37
38
39
40
41
42
import importlib
import re
import datetime
import wmk_mako_filters as wmf
def get_globals():
return {
# Allows importing modules in templates like this:
# {% set mymodule = import('mymodule') %}
'import': importlib.import_module,
# From wmk_mako_filters
'markdownify': wmf.markdownify,
'slugify': wmf.slugify,
'strip_html': wmf.strip_html,
'to_json': wmf.to_json,
'date': wmf.date,
# Note: url and fingerprint will be added to these
}
def get_filters():
return {
'date_to_iso': wmf.date_to_iso,
'date_to_rfc822': wmf.date_to_rfc822,
'date': wmf.date,
'date_short': wmf.date_short,
'date_short_us': wmf.date_short_us,
'date_long': wmf.date_long,
'date_long_us': wmf.date_long_us,
'markdownify': wmf.markdownify,
'slugify': wmf.slugify,
'truncate': wmf.truncate,
'truncatewords': wmf.truncatewords,
'p_unwrap': wmf.p_unwrap,
'strip_html': wmf.strip_html,
'cleanurl': wmf.cleanurl,
'to_json': wmf.to_json,
# TODO: add url here
}