♻️ 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:
parent
58d1fef4f1
commit
3f3634fdab
21 changed files with 80 additions and 74 deletions
|
|
@ -58,7 +58,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
|
||||
}
|
||||
|
|
@ -79,7 +79,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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
/// # }
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ fn header<'a>(response: &'a web::Response, name: &str) -> Option<&'a str> {
|
|||
|
||||
#[pagetop::test]
|
||||
async fn new_renders_the_given_markup_with_an_html_content_type() {
|
||||
let response = HtmxResponse::new(html! { li #item-42 { "New item" } }).into_response();
|
||||
let response = HtmxResponse::new(html! { li id="item-42" { "New item" } }).into_response();
|
||||
|
||||
assert_eq!(
|
||||
header(&response, "content-type"),
|
||||
|
|
@ -41,8 +41,8 @@ async fn empty_has_no_body_but_keeps_the_html_content_type() {
|
|||
|
||||
#[pagetop::test]
|
||||
async fn oob_appends_markup_after_the_main_body() {
|
||||
let response = HtmxResponse::new(html! { li #item-42 { "New item" } })
|
||||
.oob(html! { span #item-count hx-swap-oob="true" { "1" } })
|
||||
let response = HtmxResponse::new(html! { li id="item-42" { "New item" } })
|
||||
.oob(html! { span id="item-count" hx-swap-oob="true" { "1" } })
|
||||
.into_response();
|
||||
|
||||
let body = web::test::read_body_text(response).await;
|
||||
|
|
@ -58,8 +58,8 @@ async fn oob_appends_markup_after_the_main_body() {
|
|||
#[pagetop::test]
|
||||
async fn oob_can_be_called_several_times_to_accumulate_fragments() {
|
||||
let response = HtmxResponse::new(html! { p { "Main" } })
|
||||
.oob(html! { span #a hx-swap-oob="true" { "A" } })
|
||||
.oob(html! { span #b hx-swap-oob="true" { "B" } })
|
||||
.oob(html! { span id="a" hx-swap-oob="true" { "A" } })
|
||||
.oob(html! { span id="b" hx-swap-oob="true" { "B" } })
|
||||
.into_response();
|
||||
|
||||
let body = web::test::read_body_text(response).await;
|
||||
|
|
@ -76,7 +76,7 @@ async fn oob_can_be_called_several_times_to_accumulate_fragments() {
|
|||
#[pagetop::test]
|
||||
async fn oob_works_from_an_empty_response() {
|
||||
let response = HtmxResponse::empty()
|
||||
.oob(html! { span #item-count hx-swap-oob="true" { "0" } })
|
||||
.oob(html! { span id="item-count" hx-swap-oob="true" { "0" } })
|
||||
.into_response();
|
||||
|
||||
let body = web::test::read_body_text(response).await;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue