Fix empty for loop, if statements and children (#2275)
* fix empty for loop, if statements and children * fix clippy
This commit is contained in:
1 parent
40b576894f
commit
af524d979b
8 files changed
+27
-29
No files matched your search
@@ -16,6 +16,11 @@ impl<'a> TemplateRenderer<'a> {
|
||||
}
|
||||
|
||||
fn render(mut self) -> TokenStream2 {
|
||||
// If there are no roots, this is an empty template, so just return None
|
||||
if self.roots.is_empty() {
|
||||
return quote! { Option::<dioxus_core::VNode>::None };
|
||||
}
|
||||
|
||||
// Create a new dynamic context that tracks the state of all the dynamic nodes
|
||||
// We have no old template, to seed it with, so it'll just be used for rendering
|
||||
let mut context = DynamicContext::default();
|
||||
@@ -43,7 +48,7 @@ impl<'a> TemplateRenderer<'a> {
|
||||
let node_paths = context.node_paths.iter().map(|it| quote!(&[#(#it),*]));
|
||||
let attr_paths = context.attr_paths.iter().map(|it| quote!(&[#(#it),*]));
|
||||
|
||||
quote! {
|
||||
let vnode = quote! {
|
||||
static TEMPLATE: dioxus_core::Template = dioxus_core::Template {
|
||||
name: #name,
|
||||
roots: #roots,
|
||||
@@ -61,7 +66,9 @@ impl<'a> TemplateRenderer<'a> {
|
||||
);
|
||||
__vnodes
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
quote! { Some({ #vnode }) }
|
||||
}
|
||||
|
||||
fn get_template_id_tokens(&self) -> TokenStream2 {
|
||||
|
||||
Reference in new issue
Block a user