]> git.lizzy.rs Git - cheatdb.git/blob - app/template_filters.py
Fix broken link to content flags in API help page
[cheatdb.git] / app / template_filters.py
1 from . import app
2 from .utils import abs_url_for
3 from urllib.parse import urlparse
4
5 @app.context_processor
6 def inject_debug():
7     return dict(debug=app.debug)
8
9
10 @app.context_processor
11 def inject_functions():
12     return dict(abs_url_for=abs_url_for)
13
14 @app.template_filter()
15 def throw(err):
16         raise Exception(err)
17
18 @app.template_filter()
19 def domain(url):
20         return urlparse(url).netloc
21
22 @app.template_filter()
23 def date(value):
24     return value.strftime("%Y-%m-%d")
25
26 @app.template_filter()
27 def datetime(value):
28     return value.strftime("%Y-%m-%d %H:%M") + " UTC"