This repository has been archived by the owner on Feb 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.py
41 lines (35 loc) · 1.37 KB
/
main.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
# SPDX-License-Identifier: Apache-2.0
def define_env(env):
"Hook function"
# parameters are:
# address: the address prefix
# domain: the email domain, using "consensys.net" as default if not provided.
@env.macro
def email(address: str, domain: str = "consensys.net"):
return "Send email at [{address}@{domain}](mailto:{address}@{domain})".format(
address=address, domain=domain
)
# This is a demo macro that you can define for all your site
@env.macro
def color_block(value: str):
return (
'<span style="border:solid 1px black; border-right:none; '
'display:inline-block;padding:0 0.5em; vertical-align: middle;">{value}</span>'
'<span style="border:solid 1px black; background-color:{value};display:inline-block; '
'padding:0 0.5em; vertical-align: middle; width:1.5em;"> </span>'.format(
value=value
)
)
# This is a demo macro that you can define for all your site
@env.macro
def cli_to_env(name: str, prefix: str = ""):
return (
(prefix + ("_" if prefix else "") + name)
.replace("--", "")
.replace("-", "_")
.upper()
)
# This is a demo filter that you can define for all your site
@env.filter
def code(code: str):
return "`" + code + "`"