mview!() { /* proc-macro */ }
Expand description
A concise view macro for Leptos.
See module documentation for more usage details.
ยงExamples
let input = RwSignal::new(String::new());
let (red, set_red) = signal(true);
mview! {
!DOCTYPE html;
h1.title("A great website")
input
#some-id
type="text"
bind:value={input}
class:{red} // class:red={red}
on:click={move |_| set_red(false)};
// {move || !input().is_empty()}
Show when=[!input().is_empty()] (
Await
future={fetch_from_db(input())}
blocking
|db_info| (
em("DB info is: " {*db_info})
// {move || format!("{:?}", input())}
span("Query was: " f["{:?}", input()])
)
)
SlotIf cond={red} (
slot:Then("red")
slot:ElseIf cond={Signal::derive(move || input().is_empty())} ("empty")
slot:Fallback ("odd")
)
}
async fn fetch_from_db(input: String) -> usize { input.len() }