This PR adds single branch if statement capabilities into the html! macro, which is a very common use case in React-like frameworks (generally achieved with condition && <jsx/>. See an example below:
Currently to do this sort of thing is quite clunky, as if statements are expressions in rust you have to do something like the following which really bloats the components.
I appreciate this is slightly against the grain of rust as you can't do this in traditional rust code however I think it makes sense to include this functionality inside the html! macro.
I've added some unit tests for if, else and single branch if statements. I'm pretty new to rust so please let me know if you think anything could be done better. I can also add examples if required, but seems like the tests might cover that.
This PR adds single branch if statement capabilities into the html! macro, which is a very common use case in React-like frameworks (generally achieved with
condition && <jsx/>
. See an example below:Currently to do this sort of thing is quite clunky, as if statements are expressions in rust you have to do something like the following which really bloats the components.
I appreciate this is slightly against the grain of rust as you can't do this in traditional rust code however I think it makes sense to include this functionality inside the
html!
macro.I've added some unit tests for if, else and single branch if statements. I'm pretty new to rust so please let me know if you think anything could be done better. I can also add examples if required, but seems like the tests might cover that.