|
@@ -67,20 +67,9 @@ impl Parse for CallBody {
|
|
/// Serialize the same way, regardless of flavor
|
|
/// Serialize the same way, regardless of flavor
|
|
impl ToTokens for CallBody {
|
|
impl ToTokens for CallBody {
|
|
fn to_tokens(&self, out_tokens: &mut TokenStream2) {
|
|
fn to_tokens(&self, out_tokens: &mut TokenStream2) {
|
|
- let template = TemplateBuilder::from_roots(self.roots.clone());
|
|
|
|
- let inner = if let Some(template) = template {
|
|
|
|
- quote! { #template }
|
|
|
|
- } else {
|
|
|
|
- let children = &self.roots;
|
|
|
|
- if children.len() == 1 {
|
|
|
|
- let inner = &self.roots[0];
|
|
|
|
- quote! { #inner }
|
|
|
|
- } else {
|
|
|
|
- quote! { __cx.fragment_root([ #(#children),* ]) }
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+ let mut inner = TokenStream2::new();
|
|
|
|
+ self.to_tokens_without_lazynodes(&mut inner);
|
|
|
|
|
|
- // Otherwise we just build the LazyNode wrapper
|
|
|
|
out_tokens.append_all(quote! {
|
|
out_tokens.append_all(quote! {
|
|
LazyNodes::new(move |__cx: NodeFactory| -> VNode {
|
|
LazyNodes::new(move |__cx: NodeFactory| -> VNode {
|
|
use dioxus_elements::{GlobalAttributes, SvgAttributes};
|
|
use dioxus_elements::{GlobalAttributes, SvgAttributes};
|
|
@@ -107,4 +96,20 @@ impl CallBody {
|
|
})
|
|
})
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ pub fn to_tokens_without_lazynodes(&self, out_tokens: &mut TokenStream2) {
|
|
|
|
+ let template = TemplateBuilder::from_roots(self.roots.clone());
|
|
|
|
+ let inner = if let Some(template) = template {
|
|
|
|
+ quote! { #template }
|
|
|
|
+ } else {
|
|
|
|
+ let children = &self.roots;
|
|
|
|
+ if children.len() == 1 {
|
|
|
|
+ let inner = &self.roots[0];
|
|
|
|
+ quote! { #inner }
|
|
|
|
+ } else {
|
|
|
|
+ quote! { __cx.fragment_root([ #(#children),* ]) }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ out_tokens.append_all(inner);
|
|
|
|
+ }
|
|
}
|
|
}
|