Add lang tests
This commit is contained in:
parent
cbdd357b41
commit
170c0a4197
33
test/lang.tm
Normal file
33
test/lang.tm
Normal file
@ -0,0 +1,33 @@
|
||||
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>"
|
||||
|
||||
>> 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>"
|
Loading…
Reference in New Issue
Block a user