Add with_component() to region "content" in Page

This commit is contained in:
Manuel Cillero 2024-02-27 13:19:12 +01:00
parent 9be23d3cd8
commit e011cf7f62
8 changed files with 19 additions and 14 deletions

View file

@ -23,11 +23,11 @@ async fn demo(request: service::HttpRequest) -> ResultPage<Markup, ErrorPage> {
"/base/css/welcome.css",
)))
.with_body_id("welcome")
.with_component_in("content", hello_world())
.with_component_in("content", welcome())
.with_component_in("content", about_pagetop())
.with_component_in("content", promo_pagetop())
.with_component_in("content", reporting_issues())
.with_component(hello_world())
.with_component(welcome())
.with_component(about_pagetop())
.with_component(promo_pagetop())
.with_component(reporting_issues())
.render()
}

View file

@ -42,7 +42,7 @@
//!
//! async fn hello_world(request: service::HttpRequest) -> ResultPage<Markup, ErrorPage> {
//! Page::new(request)
//! .with_component_in("content", Html::with(html! { h1 { "Hello World!" } }))
//! .with_component(Html::with(html! { h1 { "Hello World!" } }))
//! .render()
//! }
//!

View file

@ -103,6 +103,13 @@ impl Page {
self
}
#[fn_with]
pub fn alter_component(&mut self, component: impl ComponentTrait) -> &mut Self {
self.regions
.add_component_in("content", ArcAnyComponent::new(component));
self
}
#[fn_with]
pub fn alter_component_in(
&mut self,

View file

@ -31,7 +31,7 @@ impl fmt::Display for ErrorPage {
let error_page = Page::new(request.clone());
if let Ok(page) = error_page
.with_title(L10n::n("Error FORBIDDEN"))
.with_component_in("content", Error403)
.with_component(Error403)
.with_template("error")
.render()
{
@ -45,7 +45,7 @@ impl fmt::Display for ErrorPage {
let error_page = Page::new(request.clone());
if let Ok(page) = error_page
.with_title(L10n::n("Error RESOURCE NOT FOUND"))
.with_component_in("content", Error404)
.with_component(Error404)
.with_template("error")
.render()
{