diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-03-09 19:03:35 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-03-09 19:03:35 -0500 |
| commit | 170c0a419794d184a941654b3b06ca12bbb9e194 (patch) | |
| tree | fdbb91db6d628de9a7510b61ac22c61df7b72f75 /test | |
| parent | cbdd357b41b4685c669755bfdd29c822d5dcc8c6 (diff) | |
Add lang tests
Diffstat (limited to 'test')
| -rw-r--r-- | test/lang.tm | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/lang.tm b/test/lang.tm new file mode 100644 index 00000000..509a4ec6 --- /dev/null +++ b/test/lang.tm @@ -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>" |
