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

Curly braces for value interpolation #152

Open
murtyjones opened this issue Aug 26, 2021 · 1 comment
Open

Curly braces for value interpolation #152

murtyjones opened this issue Aug 26, 2021 · 1 comment

Comments

@murtyjones
Copy link
Contributor

Looking over the example:

<button
    class=MY_COMPONENT_CSS
    onclick=|_event: MouseEvent| {
        web_sys::console::log_1(&"Button Clicked!".into());
    }
>

I think that requiring curly braces, similar to how React does:

class={MY_COMPONENT_CSS}

...Would be a bit more readable for the developer, and while I'm not so familiar with how syntax highlighters are built, I imagine knowing to expect {...} would be helpful for those tools too.

@chinedufn
Copy link
Owner

chinedufn commented Aug 26, 2021

Thanks for opening this issue!


Hmm. The way my eyes see it is:

"If there's a string literal (i.e. "my-class") then it's a string.. otherwise it's an identifier".

Then with blocks it would be something in the realm of "if there's a block its not a string literal, otherwise it's a string literal".

And to me, both of those seem like the same level of reading-complexity.


So, for me requiring blocks seems like unnecessary boilerplate (block expressions are supported today but not required for a single identifier).

I'm wondering whether or not blocks just make it more familiar to React developers where blocks are required (probably?) since the JS world doesn't have something like syn.
Or if blocks are truly more readable to most Rust developers (the target audience).


Also not very versed in syntax highlighting.. But I think a highlighter would know decide how to highlight based on the token type. In this case, an Ident .


Just my thoughts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants