Yew: Confusing html! macro props/attributes syntax

Created on 1 Feb 2018  路  4Comments  路  Source: yewstack/yew

Basically I want to be able to write the following:

html! {
    <div>
        <Custom />
    </div>
}

Most helpful comment

@nixpulvis You are right, macro is little strange, because we should use rules to separate identifiers and Types. I think we can improve it later with a compiler plugin (like https://github.com/tomjakubowski/json_macros do), but while it's a nightly feature.

All 4 comments

I guess I just need to add a : after the component. This is a little strange, but after reading the macro's impl I get why it's this why for the moment.

Also, not directly related, but it was causing me weird error messages. I find that needing a trailing comma shouldn't be needed, for example:

html! {
    <div class="container"></div>
}

@nixpulvis You are right, macro is little strange, because we should use rules to separate identifiers and Types. I think we can improve it later with a compiler plugin (like https://github.com/tomjakubowski/json_macros do), but while it's a nightly feature.

Fixed in 0.7

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  5Comments

IngwiePhoenix picture IngwiePhoenix  路  4Comments

jstarry picture jstarry  路  4Comments

djahandarie picture djahandarie  路  3Comments

Boscop picture Boscop  路  4Comments