by slopinthebag · 1mo ago · 0 comments
#[component]
pub fn HomePage(user: Option<User>) -> Element {
rsx! {
Layout {
title: "Home",
if let Some(u) = user {
h1 { "Welcome back, {u.name}!" }
a { href: "/users/{u.id}", "Your profile" }
} else {
h1 { "Welcome, guest!" }
a { href: "/login", "Log in" }
}
}
}
}That's not HTML though, you have to learn a whole new dsl that must conform to rust parser rules. So, not the same thing at all.
#[component]
fn App() -> impl IntoView {
let (count, set_count) = signal(0);
view! {
<button
on:click=move |_| set_count.set(3) >
"Click me”</button>
<p>{move || count.get() * 2}</p>
}
} on:click=move |_| set_count.set(3) >eg
html! {
<div onclick=|_ev: web_sys::MouseEvent| {}>
You can type text right into the elements
{ component }
{ text_var }
</div>
};this is rsx, but there are other macros that look just like html. i prefer this though, it's much more compact and readable imo
That would be great, I really like openness and ~plugin interfaces of jai compiler internals ...