diff options
author | Araq <rumpf_a@web.de> | 2014-01-18 01:16:45 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-01-18 01:16:45 +0100 |
commit | 36afdca87f3757c8468cbfa622de693447df7e07 (patch) | |
tree | 3b739b667574c12dea389a17d9d84291fd355463 /tests/showoff/thtml2.nim | |
parent | 5073914b8697a9fd1dc38bebef434b50850f2861 (diff) | |
parent | 3f8bfb1e988322ab60cc54184d63a00906260665 (diff) | |
download | Nim-36afdca87f3757c8468cbfa622de693447df7e07.tar.gz |
resolved conflicts with master
Diffstat (limited to 'tests/showoff/thtml2.nim')
-rw-r--r-- | tests/showoff/thtml2.nim | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/showoff/thtml2.nim b/tests/showoff/thtml2.nim new file mode 100644 index 000000000..8a451ebf1 --- /dev/null +++ b/tests/showoff/thtml2.nim @@ -0,0 +1,37 @@ +discard """ + output: "<html><head><title>now look at this</title></head><body><ul><li>Nimrod is quite capable</li></ul></body></html>" +""" + +import strutils + +template html(name: expr, matter: stmt) {.immediate.} = + proc name(): string = + result = "<html>" + matter + result.add("</html>") + +template nestedTag(tag: expr) {.immediate.} = + template tag(matter: stmt) {.immediate.} = + result.add("<" & astToStr(tag) & ">") + matter + result.add("</" & astToStr(tag) & ">") + +template simpleTag(tag: expr) {.immediate.} = + template tag(matter: expr) {.immediate.} = + result.add("<$1>$2</$1>" % [astToStr(tag), matter]) + +nestedTag body +nestedTag head +nestedTag ul +simpleTag title +simpleTag li + + +html mainPage: + head: + title "now look at this" + body: + ul: + li "Nimrod is quite capable" + +echo mainPage() |