-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
25 lines (22 loc) · 733 Bytes
/
example.py
File metadata and controls
25 lines (22 loc) · 733 Bytes
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
from engine import Template
template = Template("""
<h1>Hello $$name|upper$$!</h1>
<h2>You have $\x01$$account$$ in your account</h2>
$# For loop #$
$! for topic in topics !$
<p> Status: $$topic.status|upper|lower$$.</p>
$! if topic.subject !$
<p>You are interested in $$topic.subject$$.</p>
$! endif !$
$! endfor !$
<h3>Thank you for your services</h3>
""", {'upper': str.upper,'lower': str.lower})
text = template.render({
'name': "Ned",
'account': 2.00,
'topics': [{"subject":'', "status": lambda : repr(None)},
{"subject":'Python', "status": "Enjoy"},
{"subject":'Geometry', "status": "??"},
{"subject":'Juggling', "status": "Hard"}]
})
print(text)