Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dynamic tags #1266

Merged
merged 10 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion yew-macro/src/html_tree/html_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl ToTokens for HtmlComponent {
};

let key = if let Some(key) = props.key() {
quote_spanned! { key.span() => Some(#key) }
quote_spanned! { key.span()=> Some(#key) }
} else {
quote! {None }
};
Expand Down
8 changes: 7 additions & 1 deletion yew-macro/src/html_tree/html_dashed_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use syn::ext::IdentExt;
use syn::parse::{Parse, ParseStream, Result as ParseResult};
use syn::Token;

#[derive(PartialEq)]
#[derive(Clone, PartialEq)]
jstarry marked this conversation as resolved.
Show resolved Hide resolved
pub struct HtmlDashedName {
pub name: Ident,
pub extended: Vec<(Token![-], Ident)>,
Expand All @@ -22,6 +22,12 @@ impl HtmlDashedName {
extended: Vec::new(),
}
}

pub fn to_ascii_lowercase_string(&self) -> String {
let mut s = self.to_string();
s.make_ascii_lowercase();
s
}
}

impl fmt::Display for HtmlDashedName {
Expand Down
8 changes: 4 additions & 4 deletions yew-macro/src/html_tree/html_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Parse for HtmlList {
return match input.parse::<HtmlListClose>() {
Ok(close) => Err(syn::Error::new_spanned(
close,
"this closing tag has no corresponding opening tag",
"this closing fragment has no corresponding opening fragment",
)),
Err(err) => Err(err),
};
Expand All @@ -38,7 +38,7 @@ impl Parse for HtmlList {
if !HtmlList::verify_end(input.cursor()) {
return Err(syn::Error::new_spanned(
open,
"this opening tag has no corresponding closing tag",
"this opening fragment has no corresponding closing fragment",
));
}

Expand All @@ -60,9 +60,9 @@ impl ToTokens for HtmlList {
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
let children = &self.children;
let key = if let Some(key) = &self.key {
quote_spanned! {key.span() => Some(#key)}
quote_spanned! {key.span()=> Some(#key)}
} else {
quote! {None }
quote! {None}
};
tokens.extend(quote! {
::yew::virtual_dom::VNode::VList(
Expand Down
8 changes: 7 additions & 1 deletion yew-macro/src/html_tree/html_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ impl PeekValue<()> for HtmlProp {
impl Parse for HtmlProp {
fn parse(input: ParseStream) -> ParseResult<Self> {
let label = input.parse::<HtmlPropLabel>()?;
input
let equals = input
.parse::<Token![=]>()
.map_err(|_| syn::Error::new_spanned(&label, "this prop doesn't have a value"))?;
if input.is_empty() {
return Err(syn::Error::new_spanned(
equals,
"expected an expression following this equals sign",
));
}
let value = input.parse::<Expr>()?;
// backwards compat
let _ = input.parse::<Token![,]>();
Expand Down
Loading