Modifica el renderizado de contenedores internos

This commit is contained in:
Manuel Cillero 2022-03-31 00:50:53 +02:00
parent 363cec7a75
commit 48fa9e9db9
3 changed files with 20 additions and 28 deletions

View file

@ -39,34 +39,34 @@ impl PageComponent for Container {
ContainerType::Header => html! { ContainerType::Header => html! {
header id=[self.id()] class=[self.classes("header")] { header id=[self.id()] class=[self.classes("header")] {
div class="container" { div class="container" {
(self.render_components(assets)) (self.components().render(assets))
} }
} }
}, },
ContainerType::Footer => html! { ContainerType::Footer => html! {
footer id=[self.id()] class=[self.classes("footer")] { footer id=[self.id()] class=[self.classes("footer")] {
div class="container" { div class="container" {
(self.render_components(assets)) (self.components().render(assets))
} }
} }
}, },
ContainerType::Main => html! { ContainerType::Main => html! {
main id=[self.id()] class=[self.classes("main")] { main id=[self.id()] class=[self.classes("main")] {
div class="container" { div class="container" {
(self.render_components(assets)) (self.components().render(assets))
} }
} }
}, },
ContainerType::Section => html! { ContainerType::Section => html! {
section id=[self.id()] class=[self.classes("section")] { section id=[self.id()] class=[self.classes("section")] {
div class="container" { div class="container" {
(self.render_components(assets)) (self.components().render(assets))
} }
} }
}, },
_ => html! { _ => html! {
div id=[self.id()] class=[self.classes("container")] { div id=[self.id()] class=[self.classes("container")] {
(self.render_components(assets)) (self.components().render(assets))
} }
} }
} }
@ -142,6 +142,10 @@ impl Container {
&self.container &self.container
} }
pub fn components(&self) -> &PageContainer {
&self.components
}
pub fn id(&self) -> &Option<String> { pub fn id(&self) -> &Option<String> {
self.id.option() self.id.option()
} }
@ -153,12 +157,6 @@ impl Container {
pub fn template(&self) -> &str { pub fn template(&self) -> &str {
self.template.as_str() self.template.as_str()
} }
// Container EXTRAS.
pub fn render_components(&self, assets: &mut PageAssets) -> Markup {
html! { (self.components.render(assets)) }
}
} }
fn always() -> bool { fn always() -> bool {

View file

@ -51,9 +51,7 @@ impl PageComponent for Form {
method=[method] method=[method]
accept-charset=[self.charset()] accept-charset=[self.charset()]
{ {
div { div { (self.elements().render(assets)) }
(self.render_elements(assets))
}
} }
} }
} }
@ -127,6 +125,10 @@ impl Form {
&self.method &self.method
} }
pub fn elements(&self) -> &PageContainer {
&self.elements
}
pub fn id(&self) -> &Option<String> { pub fn id(&self) -> &Option<String> {
self.id.option() self.id.option()
} }
@ -138,12 +140,6 @@ impl Form {
pub fn template(&self) -> &str { pub fn template(&self) -> &str {
self.template.as_str() self.template.as_str()
} }
// Form EXTRAS.
pub fn render_elements(&self, assets: &mut PageAssets) -> Markup {
html! { (self.elements.render(assets)) }
}
} }
fn always() -> bool { fn always() -> bool {

View file

@ -58,7 +58,7 @@ impl PageComponent for MenuItem {
li class="submenu" { li class="submenu" {
a href="#" { (label) } a href="#" { (label) }
ul { ul {
(menu.render_items(assets)) (menu.items().render(assets))
} }
} }
}, },
@ -198,7 +198,7 @@ impl PageComponent for Menu {
let id = assets.serial_id(self.name(), self.id()); let id = assets.serial_id(self.name(), self.id());
html! { html! {
ul id=(id) class=[self.classes("sm sm-clean")] { ul id=(id) class=[self.classes("sm sm-clean")] {
(self.render_items(assets)) (self.items().render(assets))
} }
script type="text/javascript" defer { script type="text/javascript" defer {
"jQuery(function(){jQuery('#" (id) "').smartmenus({" "jQuery(function(){jQuery('#" (id) "').smartmenus({"
@ -251,6 +251,10 @@ impl Menu {
// Menu GETTERS. // Menu GETTERS.
pub fn items(&self) -> &PageContainer {
&self.items
}
pub fn id(&self) -> &Option<String> { pub fn id(&self) -> &Option<String> {
self.id.option() self.id.option()
} }
@ -262,12 +266,6 @@ impl Menu {
pub fn template(&self) -> &str { pub fn template(&self) -> &str {
self.template.as_str() self.template.as_str()
} }
// Menu EXTRAS.
pub fn render_items(&self, assets: &mut PageAssets) -> Markup {
html! { (self.items.render(assets)) }
}
} }
fn always() -> bool { fn always() -> bool {