46 points lukaslalinsky 1 hour ago 18 comments
slopinthebag 1 hour ago | parent
#[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" }
}
}
}
}sroerick 1 hour ago | parent
asimovDev 58 minutes ago | parent
slopinthebag 55 minutes ago | parent
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
dnautics 47 minutes ago | parent
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.
josephg 38 minutes ago | parent
#[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>
}
}skavi 14 minutes ago | parent
Humphrey 1 hour ago | parent
dnautics 48 minutes ago | parent
sorokod 31 minutes ago | parent
marcle 29 minutes ago | parent
For examples, see http://www.impredicative.com/ur/demo/
fergie 51 minutes ago | parent
jrimbault 36 minutes ago | parent
messe 33 minutes ago | parent
<!-- #include file="header.html" -->
https://en.wikipedia.org/wiki/Server_Side_Includesfergie 31 minutes ago | parent
(but yes- I used these a lot like 25 years ago)
fergie 32 minutes ago | parent
Why is there no direct support for templating in HTML itself?
cton 23 minutes ago | parent
pautasso 5 minutes ago | parent
https://web.dev/articles/imports
Been there, tried that.
Introduced in 2014 (Chrome 36) Deprecated 2018 (Chrome 70) Retired 2019 (Chrome 73)