Thank you, I know about VueJS, but I don't like it very much. I prefer to avoid
abusing HTML to recreate a Turing complete language in it - creating HTML as a
tree inside javascript makes much more sense to me. I also prefer the
declarative approach of react instead of data binding. To each one its own, I
guess :)
About the macro: I have this attempt
macro attrs*(xs: varargs[untyped]): Attrs =
let a = !"a"
var body = quote do:
var `a` {.noinit.}: Attrs
{.emit: "`a` = {};" .}
for x in xs:
let
k = x[0]
v = x[1]
body.add(quote do:
`a`.`k` = `v`
)
body.add(quote do:
return `a`
)
result = quote do:
proc inner(): Attrs =
`body`
inner()
and I feel it **should** work.
But of course it doesn't. Namely, whenever I call it, say, like this
let x = attrs(key = "hi", placeholder = "foo")
I find that `xs` (the varargs) is just `Bracket`. The parameters seem not to be
passed at all. How do macros with `varargs[untyped]` work? I am trying to pass
a variable number of... well, whatever, as long it is a piece of an AST that I
can decompose and use to extract information.