forked from mildred/nclearseam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample1.nim
24 lines (21 loc) · 796 Bytes
/
sample1.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import ../src/nclearseam
import ../src/nclearseam/jsonutil
import ../src/nclearseam/extradom
import json
import dom
import jsconsole
var config1* = create(JsonNode) do(t: auto):
t.match("h1 .name", get "name").refresh do(node: dom.Node, data: JsonNode):
node.textContent = data.getStr()
t.iter("ul li", jsonIter "names") do(name: auto):
name.match(".name").refresh do(node: dom.Node, data: JsonNode):
node.textContent = $data
var node = document.querySelector("template#sample-1")
var tmpl1* = config1.compile(node.content)
if isMainModule:
console.log(node)
console.log(tmpl1)
tmpl1.attach(node.parentNode, node, %*{"name": "Name!!!", "names": ["a", "b"]})
discard setTimeout(proc() =
tmpl1.update(%*{"name": "timeout", "names": ["a", "b", "c", "d"]})
, 1000)