Page Menu
Home
Search
Configure Global Search
Log In
Files
F13248816
jinja.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
826 B
Subscribers
None
jinja.py
View Options
"""Our custom Jinja filters and other template stuff."""
from
__future__
import
absolute_import
import
jinja2.filters
from
pillar.web.utils
import
pretty_date
from
pillar.web.nodes.routes
import
url_for_node
def
format_pretty_date
(
d
):
return
pretty_date
(
d
)
def
format_pretty_date_time
(
d
):
return
pretty_date
(
d
,
detail
=
True
)
def
format_undertitle
(
s
):
"""Underscore-replacing title filter.
Replaces underscores with spaces, and then applies Jinja2's own title filter.
"""
return
jinja2
.
filters
.
do_title
(
s
.
replace
(
'_'
,
' '
))
def
setup_jinja_env
(
jinja_env
):
jinja_env
.
filters
[
'pretty_date'
]
=
format_pretty_date
jinja_env
.
filters
[
'pretty_date_time'
]
=
format_pretty_date_time
jinja_env
.
filters
[
'undertitle'
]
=
format_undertitle
jinja_env
.
globals
[
'url_for_node'
]
=
url_for_node
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Mon, Jul 4, 3:02 PM (2 d)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
fd/5b/1a58aa5e06be800a4827d73d7efd
Attached To
rPS Pillar
Event Timeline
Log In to Comment