You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great if the view! macro allowed attributes to be set to an Optional, and then would generate the attribute if and only if the Optional is Some.
Use case:
Let's say we are wrapping a input component into our own Switch component:
#[derive(Prop)]pubstructSwitchProps<'cx>{checked:&'cx Signal<bool>,// id can be present or absent#[builder(default)]id:Option<&'cx str>,}#[component]pubfnSwitch<'a,G:Html>(cx:Scope<'a>,props:SwitchProps<'a>) -> View<G>{view!{cx,
input(type="checkbox",
role="switch",
class="...",
id=(props.id),
bind:checked=props.checked,
)}}
The SwitchProps::id prop will be present or absent depending on whether the call site specified it. But the view! macro currently does not allow it being passed through to input the same way. Instead, we have to write much more verbosely:
It would be great if the
view!
macro allowed attributes to be set to anOptional
, and then would generate the attribute if and only if the Optional is Some.Use case:
Let's say we are wrapping a
input
component into our ownSwitch
component:The
SwitchProps::id
prop will be present or absent depending on whether the call site specified it. But theview!
macro currently does not allow it being passed through toinput
the same way. Instead, we have to write much more verbosely:The text was updated successfully, but these errors were encountered: