♻️ Atributos class e id explícitos en html!

Se usa `class="..."` e `id="..."` en lugar de `div.a #x`. El HTML
generado es idéntico.
This commit is contained in:
Manuel Cillero 2026-09-26 07:05:59 +02:00
parent 58d1fef4f1
commit 3f3634fdab
21 changed files with 80 additions and 74 deletions

View file

@ -59,7 +59,7 @@ async fn homepage(request: HttpRequest) -> Result<Markup, ErrorPage> {
button hx-get="/api/hello" hx-target="#result" {
"Say hello"
}
div #result {}
div id="result" {}
}))
.render().await
}
@ -80,7 +80,7 @@ async fn homepage(request: HttpRequest) -> Result<Markup, ErrorPage> {
Page::new(request)
.with_child(Html::with(move |cx| html! {
button (props.unpack(cx)) { "Say hello" }
div #result {}
div id="result" {}
}))
.render().await
}

View file

@ -21,7 +21,7 @@ use crate::hx;
/// use pagetop_htmx::prelude::*;
///
/// async fn add_item() -> impl IntoResponse {
/// let new_item = html! { li #item-42 { "New item" } };
/// let new_item = html! { li id="item-42" { "New item" } };
///
/// HtmxResponse::new(new_item)
/// .retarget("#list")
@ -123,7 +123,7 @@ impl HtmxResponse {
///
/// # fn build_response(table: Markup, roles_count: i64) -> HtmxResponse {
/// let counter = html! {
/// span #roles-count hx-swap-oob="true" { (roles_count) }
/// span id="roles-count" hx-swap-oob="true" { (roles_count) }
/// };
/// HtmxResponse::new(table).oob(counter)
/// # }