41 points | by lukaslalinsky 1 hour ago
4 comments
For examples, see http://www.impredicative.com/ur/demo/
https://kotlinlang.org/docs/type-safe-builders.html
Why is there no direct support for templating in HTML itself?
<!-- #include file="header.html" -->
(but yes- I used these a lot like 25 years ago)
#[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" } } } } }
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'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> } }
For examples, see http://www.impredicative.com/ur/demo/
https://kotlinlang.org/docs/type-safe-builders.html
Why is there no direct support for templating in HTML itself?
(but yes- I used these a lot like 25 years ago)
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'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.