karax DSL: allow 'foo-bar' syntax for custom HTML attributes

This commit is contained in:
Araq 2018-07-03 12:56:32 +02:00
commit 015590e806

View file

@ -19,6 +19,12 @@ proc getName(n: NimNode): string =
result.add getName(n[i])
of nnkStrLit..nnkTripleStrLit:
result = n.strVal
of nnkInfix:
# allow 'foo-bar' syntax:
if n.len == 3 and $n[0] == "-":
result = getName(n[1]) & "-" & getName(n[2])
else:
expectKind(n, nnkIdent)
else:
#echo repr n
expectKind(n, nnkIdent)