blob: 01551e276345f89499c550e8e1738edcaf9b7410 (
plain)
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
|
lang HTML:
HEADER := $HTML$"<!DOCTYPE HTML>"
func escape(t:Text)->HTML:
t = t:replace("&", "&")
t = t:replace("<", "<")
t = t:replace(">", ">")
t = t:replace('"', """)
t = t:replace("'", "'")
return HTML.from_unsafe_text(t)
func escape_int(i:Int)->HTML:
return HTML.from_unsafe_text("{i}")
func paragraph(content:HTML)->HTML:
return $HTML$"<p>$content</p>"
func main():
>> HTML.HEADER
= $HTML"<!DOCTYPE HTML>"
>> user := "I <3 hax"
>> html := $HTML$"Hello $user!"
= $HTML"Hello I <3 hax!"
>> html ++ $HTML$"<br>"
= $HTML"Hello I <3 hax!<br>"
>> $HTML{}"{1 + 2}"
= $HTML"3"
>> $HTML{}"{3_i8}"
= $HTML"3"
>> html:paragraph()
= $HTML"<p>Hello I <3 hax!</p>"
>> Text(html)
= "$HTML\"Hello I <3 hax!\""
|