-
Notifications
You must be signed in to change notification settings - Fork 35
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
Leptosfmt removes neccesary curly brackets #138
Comments
I don't think that is true, as See: https://github.com/rs-tml/rstml/blob/23ba0d346337a6019826d32e4124aa41bac82c27/rstml/src/node/attribute.rs#L254C28-L254C50 and from the readme:
That said, this behaviour can be customized through the Could you provide me a full stacktrace so that I can see where the error originated from? Or a minimum reproducible example? In the meantime, you could try to set the |
And which leptos version are you using? |
Sure, here is a minimal example. I'm on leptos 0.7.0-beta so maybe the view macro changed? Cargo.toml: [package]
name = "t"
version = "0.1.0"
edition = "2021"
[dependencies]
leptos = { version = "0.7.0-beta" }
strum = { version = "0.26.3", features = ["derive"] } src/main.rs: use leptos::prelude::*;
use strum::{Display, EnumIter, IntoStaticStr};
#[derive(Clone, Debug, Display, EnumIter, IntoStaticStr)]
enum AnEnum {
One,
Two,
Three,
}
#[component]
fn App() -> impl IntoView {
let variants = vec![AnEnum::One, AnEnum::Two, AnEnum::Three];
view! {
<select>
{variants
.into_iter()
.map(|variant| {
view! {
<option value={Into::<&'static str>::into(variant)}>{variant.to_string()}</option>
}
})
.collect_view()}
</select>
}
}
fn main() {
mount_to_body(App)
} Which compiles just fine. After running:
I get this: use leptos::prelude::*;
use strum::{Display, EnumIter, IntoStaticStr};
#[derive(Clone, Debug, Display, EnumIter, IntoStaticStr)]
enum AnEnum {
One,
Two,
Three,
}
#[component]
fn App() -> impl IntoView {
let variants = vec![AnEnum::One, AnEnum::Two, AnEnum::Three];
view! {
<select>
{variants
.into_iter()
.map(|variant| {
view! {
<option value=Into::<
&'static str,
>::into(variant)>{variant.to_string()}</option>
}
})
.collect_view()}
</select>
}
}
fn main() {
mount_to_body(App)
} Which doesn't compile:
|
Also I'm on leptosfmt version 0.1.30 |
Thanks! I will try to check it somewhere this week. Does using the Regarding leptos 0.7 beta, there are some discussions about enforcing braces, but that PR has not been merged yet: leptos-rs/leptos#2769 |
Oops sorry missed that part of your message, yes, attr_value_brace_style=Preserve fixes the issue, thanks! |
I have this code inside a view:
Which compiles just fine. But if I run leptosfmt, it is formatted to this:
Where the curly brackets around the Into call are removed. This leads to a parser error from the view macro:
error: failed to parse expression: unexpected end of input, expected one of:
for
, parentheses,fn
,unsafe
,extern
, identifier,::
,<
,dyn
, square brackets,*
,&
,!
,impl
,_
, lifetime--> src/components/slides/report/one.rs:60:51
|
60 | ... <option value=Into::<
| ^^^^
Since the end of the Into call generic is interpreted as the end of the <option tag
The text was updated successfully, but these errors were encountered: