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

Odd comment handling inside of view! #111

Closed
qrilka opened this issue Mar 2, 2024 · 1 comment · Fixed by #120
Closed

Odd comment handling inside of view! #111

qrilka opened this issue Mar 2, 2024 · 1 comment · Fixed by #120
Labels
wontfix This will not be worked on

Comments

@qrilka
Copy link

qrilka commented Mar 2, 2024

Originall reported in #106 (comment)
Small example:

$ echo -e 'fn bar(){\n// comment in rust\nview!{\n if true {\n // comment in view\n let x = 42;\n view!{ X } view!{ Y }}\n}}' | rustfmt
fn bar() {
    // comment in rust
    view! {
     if true {
     // comment in view
     let x = 42;
     view!{ X } view!{ Y }}
    }
}
$ echo -e 'fn bar(){\n// comment in rust\nview!{\n if true {\n // comment in view\n let x = 42;\n view!{ X } view!{ Y }}\n}}' | leptosfmt -s --ru
stfmt
fn bar() {
    // comment in rust
    view! {
        if true
        {
            let x = 42;
            view! {
                // comment in view
                X
            }
            view! {
                // comment in view
                Y
            }
        }
    }
}

Comment gets moved into all the following view!s

@bram209
Copy link
Owner

bram209 commented May 24, 2024

Hi, this is expected behaviour. See the readme on non-doc comments for an explanation.
Regular comments are supported in the view! macro, but not inside rust code that resides within the view! macro.

fn bar() {
    // comment in rust
    view! {
        if true
        {
            // comment in view <- this is a comment in a rust code block inside a view and therefore is stripped out by the `prettyplease` crate
            let x = 42;
            view! {
                // comment in view
                X
            }
            view! {
                // comment in view
                Y
            }
        }
    }
}

@bram209 bram209 added the wontfix This will not be worked on label May 24, 2024
@bram209 bram209 closed this as completed May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants