Merge pull request #12 from alehander42/fix-17

Fix some issues with v0.17
This commit is contained in:
Andreas Rumpf 2017-05-18 10:12:11 +02:00 • committed by GitHub
commit 68134abe3f
2 changed files with 8 additions and 6 deletions

View file

@ -79,8 +79,8 @@ proc stateDecl(n: NimNode; names: TableRef[string, bool]; decl: NimNode) =
for i in 0 .. c.len-3: for i in 0 .. c.len-3:
let v = $c[i] let v = $c[i]
let sv = toState v let sv = toState v
decl.add quote do: decl.add(quote do:
var `sv` = newStateDict[`usedType`]() var `sv` = newStateDict[`usedType`]())
if val.kind != nnkEmpty: if val.kind != nnkEmpty:
decl.add newTree(nnkAsgn, newDotExpr(sv, newIdentNode"defaultValue"), decl.add newTree(nnkAsgn, newDotExpr(sv, newIdentNode"defaultValue"),
val) val)

View file

@ -101,20 +101,22 @@ proc tcall2(n, tmpContext: NimNode): NimNode =
result = n result = n
macro buildHtml*(tag, children: untyped): VNode = macro buildHtml*(tag, children: untyped): VNode =
expectKind children, nnkDo let kids = newProc(procType=nnkDo, body=children)
expectKind kids, nnkDo
var call: NimNode var call: NimNode
if tag.kind in nnkCallKinds: if tag.kind in nnkCallKinds:
call = tag call = tag
else: else:
call = newCall(tag) call = newCall(tag)
call.add body(children) call.add body(kids)
result = tcall2(call, nil) result = tcall2(call, nil)
when defined(debugKaraxDsl): when defined(debugKaraxDsl):
echo repr result echo repr result
macro buildHtml*(children: untyped): VNode = macro buildHtml*(children: untyped): VNode =
expectKind children, nnkDo let kids = newProc(procType=nnkDo, body=children)
result = tcall2(body(children), nil) expectKind kids, nnkDo
result = tcall2(body(kids), nil)
when defined(debugKaraxDsl): when defined(debugKaraxDsl):
echo repr result echo repr result