wip: move some examples around
This commit is contained in:
1 parent
cca7c5fc3a
commit
98a09339fd
70 files changed
+111
-117
No files matched your search
@@ -39,7 +39,7 @@ impl Parse for HtmlRender {
|
||||
return input.parse::<LitStr>()?.parse::<HtmlRender>();
|
||||
}
|
||||
|
||||
// let cx: Ident = s.parse()?;
|
||||
// let __cx: Ident = s.parse()?;
|
||||
// s.parse::<Token![,]>()?;
|
||||
// if elements are in an array, return a bumpalo::collections::Vec rather than a Node.
|
||||
let kind = if input.peek(token::Bracket) {
|
||||
@@ -64,8 +64,8 @@ impl ToTokens for HtmlRender {
|
||||
|
||||
// create a lazy tree that accepts a bump allocator
|
||||
let final_tokens = quote! {
|
||||
dioxus::prelude::LazyNodes::new(move |cx| {
|
||||
let bump = &cx.bump();
|
||||
dioxus::prelude::LazyNodes::new(move |__cx| {
|
||||
let bump = __cx.bump();
|
||||
|
||||
#new_toks
|
||||
})
|
||||
@@ -152,16 +152,18 @@ struct Element {
|
||||
|
||||
impl ToTokens for ToToksCtx<&Element> {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
||||
// let cx = self.cx;
|
||||
let name = &self.inner.name.to_string();
|
||||
// let __cx = self.__cx;
|
||||
let name = &self.inner.name;
|
||||
// let name = &self.inner.name.to_string();
|
||||
tokens.append_all(quote! {
|
||||
dioxus::builder::ElementBuilder::new(cx, #name)
|
||||
__cx.element(dioxus_elements::#name)
|
||||
// dioxus::builder::ElementBuilder::new( #name)
|
||||
});
|
||||
for attr in self.inner.attrs.iter() {
|
||||
self.recurse(attr).to_tokens(tokens);
|
||||
}
|
||||
|
||||
if is_valid_svg_tag(name) {
|
||||
if is_valid_svg_tag(&name.to_string()) {
|
||||
tokens.append_all(quote! {
|
||||
.namespace(Some("http://www.w3.org/2000/svg"))
|
||||
});
|
||||
|
||||
@@ -18,7 +18,6 @@ use syn::{
|
||||
pub enum AmbiguousElement {
|
||||
Element(Element),
|
||||
Component(Component),
|
||||
Fragment(Fragment),
|
||||
}
|
||||
|
||||
impl Parse for AmbiguousElement {
|
||||
@@ -76,7 +75,6 @@ impl ToTokens for AmbiguousElement {
|
||||
match self {
|
||||
AmbiguousElement::Element(el) => el.to_tokens(tokens),
|
||||
AmbiguousElement::Component(comp) => comp.to_tokens(tokens),
|
||||
AmbiguousElement::Fragment(frag) => frag.to_tokens(tokens),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,14 +133,17 @@ impl ToTokens for Component {
|
||||
|
||||
let childs = &self.children;
|
||||
let children = quote! {
|
||||
ChildrenList::new(__cx)
|
||||
#( .add_child(#childs) )*
|
||||
.finish()
|
||||
[ #( #childs ),* ]
|
||||
};
|
||||
// ChildrenList::new(__cx)
|
||||
// #( .add_child(#childs) )*
|
||||
// .finish()
|
||||
// ChildrenList::new(__cx)
|
||||
// #( .add_child(#childs) )*
|
||||
// .finish()
|
||||
|
||||
tokens.append_all(quote! {
|
||||
dioxus::builder::virtual_child(
|
||||
__cx,
|
||||
__cx.virtual_child(
|
||||
#name,
|
||||
#builder,
|
||||
#key_token,
|
||||
|
||||
@@ -86,13 +86,13 @@ impl ToTokens for RsxRender {
|
||||
match &self.custom_context {
|
||||
// The `in cx` pattern allows directly rendering
|
||||
Some(ident) => out_tokens.append_all(quote! {
|
||||
#ident.render(dioxus::prelude::LazyNodes::new(move |__cx: &NodeFactory|{
|
||||
#ident.render(dioxus::prelude::LazyNodes::new(move |__cx: NodeFactory|{
|
||||
#inner
|
||||
}))
|
||||
}),
|
||||
// Otherwise we just build the LazyNode wrapper
|
||||
None => out_tokens.append_all(quote! {
|
||||
dioxus::prelude::LazyNodes::new(move |__cx: &NodeFactory|{
|
||||
dioxus::prelude::LazyNodes::new(move |__cx: NodeFactory|{
|
||||
#inner
|
||||
})
|
||||
}),
|
||||
|
||||
Reference in new issue
Block a user