docs: big updates to the reference

This commit is contained in:
Jonathan Kelley committed 2021-07-16 16:11:25 -04:00
1 parent caf772cf24
commit 583fdfa561
57 files changed
+726 -247

No files matched your search

+8 -22
View File
@@ -39,32 +39,18 @@ impl Parse for AmbiguousElement {
}
}
// if input.peek(Ident) {
// let name_str = input.fork().parse::<Ident>().unwrap().to_string();
// } else {
// }
if let Ok(name) = input.fork().parse::<Ident>() {
let name_str = name.to_string();
match is_valid_tag(&name_str) {
true => input
let first_char = name_str.chars().next().unwrap();
if first_char.is_ascii_uppercase() {
input
.parse::<Component>()
.map(|c| AmbiguousElement::Component(c))
} else {
input
.parse::<Element>()
.map(|c| AmbiguousElement::Element(c)),
false => {
let first_char = name_str.chars().next().unwrap();
if first_char.is_ascii_uppercase() {
input
.parse::<Component>()
.map(|c| AmbiguousElement::Component(c))
} else {
let name = input.parse::<Ident>().unwrap();
Err(Error::new(
name.span(),
"Components must be uppercased, perhaps you mispelled a html tag",
))
}
}
.map(|c| AmbiguousElement::Element(c))
}
} else {
if input.peek(LitStr) {
+2 -2
View File
@@ -96,7 +96,7 @@ pub fn parse_component_body(
}
content.parse::<Token![..]>()?;
*manual_props = Some(content.parse::<Expr>()?);
} else if content.peek(Ident) && content.peek2(Token![:]) {
} else if content.peek(Ident) && content.peek2(Token![:]) && !content.peek3(Token![:]) {
if !cfg.allow_fields {
return Err(Error::new(
content.span(),
@@ -184,7 +184,7 @@ impl ToTokens for Component {
};
tokens.append_all(quote! {
__cx.virtual_child(
__cx.component(
#name,
#builder,
#key_token,
-5
View File
@@ -43,11 +43,6 @@ impl Parse for Element {
fn parse(stream: ParseStream) -> Result<Self> {
let name = Ident::parse(stream)?;
// TODO: remove this in favor of the compile-time validation system
if !crate::util::is_valid_tag(&name.to_string()) {
return Err(Error::new(name.span(), "Not a valid Html tag"));
}
// parse the guts
let content: ParseBuffer;
syn::braced!(content in stream);