-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buildHtml to take multiple elements #7
Comments
Huh? Pretty sure I have code like this. |
Hm, okay not sure what could be different. Here's my full example to reproduce: include karaxprelude
proc renderer(): VNode =
result = buildHtml():
tdiv():
text "test"
tdiv():
text "test"
setRenderer renderer Running with updated karax & nim devel branches this afternoon. And the output of running with
Strange that the symbol is not actually a symbol of the macro. |
Oh yeah, well that can't work, there is no root node to attach the 2 divs to. Maybe the buildHtml that only takes children is a bad idea. :-) |
Shouldn't there be the main/global entry point of the app A use case for a "multiple children buildHtml" would be: proc renderList(): VNode =
# don't want to make a decision about the container here
result = buildHtml():
tdiv():
text "child 1"
tdiv():
text "child 2"
proc renderer(): VNode =
result = buildHtml():
tdiv():
renderList()
aDifferentContainer():
renderList() This is by the way one of the limitations in Vue (each component must have a single root) and often results in wrapping things in slightly annoying dummy divs. |
We can perhaps introdue a special |
Yes, this is probably not so easy. The question is whether a The first idea was to fully switch to lists of nodes, because html itself is always a list of nodes within The other idea is to stay with a single proc renderList(parent: VNode): VNode =
# don't want to make a decision about the container here
# solved by forwarding the parent to buildHtml
result = buildHtml(parent):
tdiv():
text "child 1"
tdiv():
text "child 2"
proc renderer(): VNode =
result = buildHtml():
tdiv():
renderList(currentNode)
aDifferentContainer():
renderList(currentNode) This might clash (or rather confuse people) with the current overload of # Writing the root tag in the body looks good to me
result = buildHtml():
tdiv(id="A"):
tdiv(id="sub"):
text "a"
# Do we need support for this, any benefit?
result = buildHtml(tdiv(id="A")):
tdiv(id="sub"):
text "a" This second solution should work fine for inner levels -- on the outermost level it could be tricky if it requires e.g. a dummy parent. |
FYI: Inspired by Karax, I wrote a similar DSL to generate SVG files/animations. As an experiment I modified the DSL in a way that the main |
I second this feature. |
I'm going to close this for now due to inactivity. It sounds like this may be able to be supported in the future, but is not currently. Please feel free to re-open and comment if you want to discuss further! |
Not sure if this is by design, but having multiple top level elements in
buildHtml
does not seem to work:Leads to:
Error: expression 'tmp94011' is of type 'VNode' and has to be discarded
Wrapping them into one top level element solve the problem.
The text was updated successfully, but these errors were encountered: