Yew html! question

Is there any yew users here?

Any idea how one can do a loop in html!?

html!{
            <table>
            {
            for f in self.foo.map {
                <tr>
                    <td>{ f.name }</td>
                    <td>{ f.value }</td>
                </tr>
            }
            }
            </table>
        }
1 Like

What is the type of self.foo.map? Looking at https://github.com/DenisKolodin/yew/blob/master/examples/large_table/src/lib.rs I would think that would work.

You could try for f in self.foo

Thanks for the tip, this worked.

            <table>
                {
                    for self.foo.iter().map(|row|{
                        view_row(row)
                    })
                }
            </table>

Seem like for in html! has special meaning. It does not work like regular for in rust syntax for loop

1 Like

Yes, you will find that this is the case as long as

html! {
     <> 
         { for $x }
     </>
}

$x must work in the following situation:

for i in $x {}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.