Multiple root nodes #55
-
Hello, Are there any plans of supporting multiple root nodes when writing html? This is not a major blocker for me but having the possibility to return multiple root nodes will make it a bit easier to work with semantic html, and make the html a bit easier to read. Vue only used one root-node in v1/2 but switched to a multi-root setup in the new vue 3. Discussions and links can be found here link. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I'm not entirely sure what you mean, dominator has always supported multiple root nodes: dominator::append_dom(&dominator::body(), Root1::render());
dominator::append_dom(&dominator::body(), Root2::render()); You can append the root wherever you want, it doesn't have to be in the body: |
Beta Was this translation helpful? Give feedback.
-
I also find it useful to use a dummy container so that it expresses the intent, has inline styling, and basically behaves like an empty fragment in terms of layout: html!("empty-fragment", {
.children(&mut render_header(app, route))
.children(&mut render_button(app, text, route))
.children(&mut render_button(app, text, route))
.children(&mut render_footer(app, route))
}) fwiw, even though all of this does mean additional nesting, in practice I don't find that to be a real problem at all, just slightly more annoying to debug in the browser itself (but that's difficult with modern web dev anyway, e.g. auto-generated class names and so on) |
Beta Was this translation helpful? Give feedback.
I'm not entirely sure what you mean, dominator has always supported multiple root nodes:
You can append the root wherever you want, it doesn't have to be in the body:
rust-dominator/examples/todomvc/src/lib.rs
Line 13 in ac5391e