fix formatted strings in components

This commit is contained in:
Evan Almloff committed 2024-01-16 12:47:23 -06:00
1 parent 407a82588a
commit 90d0164b9e
8 files changed
+41 -59

No files matched your search

+2 -2
View File
@@ -211,7 +211,7 @@ impl ToTokens for ElementAttrValue {
fn to_tokens(&self, tokens: &mut TokenStream2) {
match self {
ElementAttrValue::Shorthand(i) => tokens.append_all(quote! { #i }),
ElementAttrValue::AttrLiteral(lit) => tokens.append_all(quote! { #lit }),
ElementAttrValue::AttrLiteral(lit) => tokens.append_all(quote! { #lit.to_string() }),
ElementAttrValue::AttrOptionalExpr { condition, value } => {
tokens.append_all(quote! { if #condition { Some(#value) } else { None } })
}
@@ -224,7 +224,7 @@ impl ToTokens for ElementAttrValue {
impl ElementAttrValue {
fn to_str_expr(&self) -> Option<TokenStream2> {
match self {
ElementAttrValue::AttrLiteral(lit) => Some(quote!(#lit)),
ElementAttrValue::AttrLiteral(lit) => Some(quote!(#lit.to_string())),
ElementAttrValue::AttrOptionalExpr { value, .. } => value.to_str_expr(),
ElementAttrValue::AttrExpr(expr) => Some(quote!(#expr.to_string())),
_ => None,
+1 -1
View File
@@ -242,7 +242,7 @@ impl ToTokens for IfmtInput {
.map(|ident| quote!(#ident = #ident));
quote! {
format!(
::std::format_args!(
#format_literal
#(, #positional_args)*
#(, #named_args)*
+1 -1
View File
@@ -144,7 +144,7 @@ impl ToTokens for BodyNode {
}
BodyNode::Component(comp) => comp.to_tokens(tokens),
BodyNode::Text(txt) => tokens.append_all(quote! {
dioxus_core::DynamicNode::Text(dioxus_core::VText::new(#txt))
dioxus_core::DynamicNode::Text(dioxus_core::VText::new(#txt.to_string()))
}),
BodyNode::RawExpr(exp) => tokens.append_all(quote! {
{