♻️ (bootsier, htmx): Adapta ciclo de render async
Añade `#[async_trait]` a todos los `impl Extension`, `Theme` y `Component`. Convierte `prepare()` en `async fn` y añade `.await` a las llamadas `render()` y `render_offcanvas()`.
This commit is contained in:
parent
9354894b3a
commit
1139df6210
17 changed files with 68 additions and 42 deletions
|
|
@ -34,6 +34,7 @@ use pagetop::prelude::*;
|
|||
|
||||
struct MyApp;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for MyApp {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![
|
||||
|
|
@ -59,7 +60,7 @@ async fn homepage(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
|||
}
|
||||
div #result {}
|
||||
}))
|
||||
.render()
|
||||
.render().await
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ pub const DISABLE: &str = "hx-disable";
|
|||
|
||||
/// Genera `hx-on:{event}` para escuchar eventos nativos del DOM en línea.
|
||||
///
|
||||
/// Es la alternativa de HTMX a los manejadores `on*` de HTML (`onclick`, `onmouseenter`, ...). La
|
||||
/// Es la alternativa de HTMX a los *handlers* `on*` de HTML (`onclick`, `onmouseenter`, ...). La
|
||||
/// diferencia clave está en cómo los trata el navegador bajo una política CSP (*Content Security
|
||||
/// Policy*): los atributos `on*` son JavaScript en línea y quedan bloqueados si la CSP no incluye
|
||||
/// `'unsafe-inline'`; en cambio, `hx-on:*` es un atributo de datos que HTMX lee e interpreta desde
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ use pagetop::prelude::*;
|
|||
|
||||
struct MyApp;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for MyApp {
|
||||
fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
vec![
|
||||
|
|
@ -60,7 +61,7 @@ async fn homepage(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
|||
}
|
||||
div #result {}
|
||||
}))
|
||||
.render()
|
||||
.render().await
|
||||
}
|
||||
```
|
||||
*/
|
||||
|
|
@ -91,6 +92,7 @@ include_locales!(LOCALES_HTMX);
|
|||
///
|
||||
/// struct MyApp;
|
||||
///
|
||||
/// #[async_trait]
|
||||
/// impl Extension for MyApp {
|
||||
/// fn dependencies(&self) -> Vec<ExtensionRef> {
|
||||
/// vec![
|
||||
|
|
@ -103,6 +105,7 @@ include_locales!(LOCALES_HTMX);
|
|||
/// ```
|
||||
pub struct Htmx;
|
||||
|
||||
#[async_trait]
|
||||
impl Extension for Htmx {
|
||||
fn name(&self) -> L10n {
|
||||
L10n::t("extension_name", &LOCALES_HTMX)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use pagetop::prelude::*;
|
|||
/// .with_child(Html::with(|_| html! {
|
||||
/// ul { li { "Item 1" } li { "Item 2" } }
|
||||
/// }))
|
||||
/// .render()
|
||||
/// .render().await
|
||||
/// .into_response()
|
||||
/// }
|
||||
/// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue