M .gitignore => .gitignore +1 -0
@@ 1,1 1,2 @@
.tup
+test_patterns
M src/svui.nim => src/svui.nim +7 -6
@@ 1,13 1,14 @@
import
- std/typetraits, preserves
+ std/typetraits, preserves, std/tables
type
- Svui* {.preservesRecord: "svui".} = object
+ Svui*[E] {.preservesRecord: "svui".} = ref object
+ `attrs`*: Table[string, Preserve[E]]
`svg`*: string
-proc `$`*(x: Svui): string =
- `$`(toPreserve(x))
+proc `$`*[E](x: Svui[E]): string =
+ `$`(toPreserve(x, E))
-proc encode*(x: Svui): seq[byte] =
- encode(toPreserve(x))
+proc encode*[E](x: Svui[E]): seq[byte] =
+ encode(toPreserve(x, E))
M svui.prs => svui.prs +1 -1
@@ 1,3 1,3 @@
version 1.
-Svui = <svui @svg string>.
+Svui = <svui @attrs {symbol: any ...:...} @svg string>.
A tests/test_patterns.nim => tests/test_patterns.nim +11 -0
@@ 0,0 1,11 @@
+import std/[typetraits, unittest]
+import preserves
+import syndicate/patterns
+import svui
+
+type Svui = svui.Svui[void]
+
+suite "patterns":
+ test "grab-all":
+ let pat = Svui ? {0: grab(), 1: grab()}
+ check $pat == "<compound <rec svui 2> {0: <bind <_>>, 1: <bind <_>>}>"