By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 jinja_utils.py

View raw Download
text/x-script.python • 543 B
Python script, ASCII text executable
        
            
1
from app import app
2
from datetime import datetime
3
4
5
@app.template_filter("split")
6
def split(value: str, separator=" ", maxsplit: int = -1):
7
return value.split(separator, maxsplit)
8
9
10
@app.template_filter("strftime")
11
def strftime(value: datetime, syntax: str):
12
return value.strftime(syntax)
13
14
15
@app.template_filter("unixtime")
16
def strftime(value: datetime):
17
return round(value.timestamp())
18
19
20
@app.template_filter("decode")
21
def decode(value: bytes, codec: str = "UTF-8", errors: str = "strict"):
22
return value.decode(codec, errors)
23