Add a ton of comments to rsx/hotreload, add snapshot testing, refactor a bit to simplify the crate (#2130)

Merge dynamic context and dynamic mapping, clean up the rsx hotreload logic, and add location data to the Rsx objects
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-03-24 13:31:26 -07:00
1 parent b19a546c0a
commit eb79e61642
31 files changed
+1413 -811

No files matched your search

+7 -13
View File
@@ -11,6 +11,8 @@
//! - [ ] Keys
//! - [ ] Properties spreading with with `..` syntax
use self::{location::CallerLocation, renderer::TemplateRenderer};
use super::*;
use proc_macro2::TokenStream as TokenStream2;
@@ -32,6 +34,7 @@ pub struct Component {
pub children: Vec<BodyNode>,
pub manual_props: Option<Expr>,
pub brace: syn::token::Brace,
pub location: CallerLocation,
}
impl Parse for Component {
@@ -88,6 +91,7 @@ impl Parse for Component {
}
Ok(Self {
location: CallerLocation::default(),
name,
prop_gen_args,
fields,
@@ -179,20 +183,10 @@ impl Component {
toks.append_all(quote! {#field})
}
if !self.children.is_empty() {
let renderer: TemplateRenderer = TemplateRenderer {
roots: &self.children,
location: None,
};
toks.append_all(quote! {
.children(
Some({ #renderer })
)
});
let renderer = TemplateRenderer::as_tokens(&self.children, None);
toks.append_all(quote! { .children( Some({ #renderer }) ) });
}
toks.append_all(quote! {
.build()
});
toks.append_all(quote! { .build() });
toks
}