I'm submitting a question.
I just read about Yew, while looking for a way to utillize WebAssembly in my application. However, what sprung right to my eye was the JSX-ish syntax: There are commans all over in the examples. How come? Would...
html! (
<div id="foo">
<button
name="something"
onClick=|_| ...
>
{"Click me"}
</button>
);
Be invalid? I am new to Rust, by the way. :) I come from C++.
Kind regards,
Ingwie
Hi! The comma is a temporary restriction of the current html! macro implementation. Yew uses pure Rust expressions everywhere (string is also an expression) and we have to know where an expression ends, for example, we need to know the bounds of the of following examples:
<div id=variable>
<div id=variable>0>
The solution is to separate them by a comma:
<div id=variable,>
<div id=variable>0,>
But I do some experimentation with a new macro implementation that will be more familiar to JSX users.
I see! That explains a lot.
Thank you very much for explaining to me =)
@IngwiePhoenix a change was just merged to master that no longer requires commas. It will be released in the near future but if you want to try it out now you can update your yew dependency in your Cargo.toml file to:
yew = { git = "https://github.com/DenisKolodin/yew", features = ["proc_macro"] }
Commas are no longer required in the recently released 0.7.0, so this issue can be closed :slightly_smiling_face:
By the way, can you rename it to something like questions: are commas mandatory in yew's JSX?
Most helpful comment
Hi! The comma is a temporary restriction of the current
html!macro implementation. Yew uses pure Rust expressions everywhere (string is also an expression) and we have to know where an expression ends, for example, we need to know the bounds of the of following examples:The solution is to separate them by a comma:
But I do some experimentation with a new macro implementation that will be more familiar to JSX users.