diff options
author | Simon Hafner <hafnersimon@gmail.com> | 2014-03-31 15:49:04 -0500 |
---|---|---|
committer | Simon Hafner <hafnersimon@gmail.com> | 2014-03-31 15:49:04 -0500 |
commit | ffb36db5a6caa147119aed1728c8042dfa68a3e8 (patch) | |
tree | 0db6e9c9b39a21511cf6d5a1c2f489e35a10ed60 /tests/template/tissue993.nim | |
parent | 565031f0cd4768962fb19ac4e17efb994dfb4735 (diff) | |
parent | 44ee8aecfd70d1d381b5eed5ae52b01fae04452b (diff) | |
download | Nim-ffb36db5a6caa147119aed1728c8042dfa68a3e8.tar.gz |
Merge branch 'devel' of github.com:Araq/Nimrod into seq_toString
Diffstat (limited to 'tests/template/tissue993.nim')
-rw-r--r-- | tests/template/tissue993.nim | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/template/tissue993.nim b/tests/template/tissue993.nim new file mode 100644 index 000000000..d39f43942 --- /dev/null +++ b/tests/template/tissue993.nim @@ -0,0 +1,21 @@ + +type pnode* = ref object of tobject + +template litNode (name, ty): stmt = + type name* = ref object of PNode + val*: ty +litNode PIntNode, int + +import json + +template withKey*(j: PJsonNode; key: string; varname: expr; + body:stmt): stmt {.immediate.} = + if j.hasKey(key): + let varname{.inject.}= j[key] + block: + body + +var j = parsejson("{\"zzz\":1}") +withkey(j, "foo", x): + echo(x) + |