♻️ (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:
Manuel Cillero 2026-07-06 07:55:30 +02:00
parent 9354894b3a
commit 1139df6210
17 changed files with 68 additions and 42 deletions

View file

@ -44,6 +44,7 @@ pub struct Nav {
items: Children,
}
#[async_trait]
impl Component for Nav {
fn new() -> Self {
Self::default()
@ -63,8 +64,8 @@ impl Component for Nav {
}));
}
fn prepare(&self, cx: &mut Context) -> Result<Markup, ComponentError> {
let items = self.items().render(cx);
async fn prepare(&self, cx: &mut Context) -> Result<Markup, ComponentError> {
let items = self.items().render(cx).await;
if items.is_empty() {
return Ok(html! {});
}

View file

@ -65,6 +65,7 @@ pub struct Item {
item_kind: ItemKind,
}
#[async_trait]
impl Component for Item {
fn new() -> Self {
Self::default()
@ -78,7 +79,7 @@ impl Component for Item {
self.alter_prop(PropsOp::prepend_classes(self.item_kind().as_str()));
}
fn prepare(&self, cx: &mut Context) -> Result<Markup, ComponentError> {
async fn prepare(&self, cx: &mut Context) -> Result<Markup, ComponentError> {
Ok(match self.item_kind() {
ItemKind::Void => html! {},
@ -133,13 +134,13 @@ impl Component for Item {
ItemKind::Html(html) => html! {
li (self.props()) {
(html.render(cx))
(html.render(cx).await)
}
},
ItemKind::Dropdown(menu) => {
if let Some(dd) = menu.get() {
let items = dd.items().render(cx);
let items = dd.items().render(cx).await;
if items.is_empty() {
return Ok(html! {});
}