aboutsummaryrefslogtreecommitdiff
path: root/test/lang.tm
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-01 16:04:14 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-03-01 16:04:14 -0500
commitfab0083129c134a49c77a4f7e3b333f1e0f14d55 (patch)
treef4d493712a7b9ebad9ab4136bd1fa25ec4e933d6 /test/lang.tm
parent90548ebb33ea69c6c9e0962d8bab6d3ec72ac90f (diff)
Support post-hoc definitions of escaping rules for DSLs
Diffstat (limited to 'test/lang.tm')
-rw-r--r--test/lang.tm9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/lang.tm b/test/lang.tm
index 77fd7958..5d8c619e 100644
--- a/test/lang.tm
+++ b/test/lang.tm
@@ -17,6 +17,10 @@ lang HTML:
func paragraph(content:HTML->HTML):
return $HTML"<p>$content</p>"
+struct Bold(text:Text):
+ func HTML(b:Bold -> HTML):
+ return $HTML"<b>$(b.text)</b>"
+
func main():
>> HTML.HEADER
= $HTML"<!DOCTYPE HTML>"
@@ -44,3 +48,8 @@ func main():
>> Text(html)
= '$HTML"Hello I &lt;3 hax!"'
+
+ >> b := Bold("Some <text> with junk")
+ >> $HTML"Your text: $b"
+ = $HTML"Your text: <b>Some &lt;text&gt; with junk</b>"
+