🚧 Ensure block has renderable content
This commit is contained in:
parent
571586e587
commit
c2d0c2a80d
1 changed files with 13 additions and 14 deletions
|
|
@ -31,24 +31,23 @@ impl ComponentTrait for Block {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_before_prepare(&mut self, _cx: &mut Context) {
|
fn setup_before_prepare(&mut self, _cx: &mut Context) {
|
||||||
self.classes.alter_value(ClassesOp::AddFirst, "block");
|
self.classes.alter_value(ClassesOp::AddFirst, "pt-block");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||||
if self.components().is_empty() {
|
let block_body = self.components().render(cx);
|
||||||
return PrepareMarkup::None;
|
if !block_body.is_empty() {
|
||||||
|
let id = cx.required_id::<Block>(self.id());
|
||||||
|
return PrepareMarkup::With(html! {
|
||||||
|
div id=(id) class=[self.classes().get()] {
|
||||||
|
@if let Some(title) = self.title().using(cx.langid()) {
|
||||||
|
h2 class="pt-block__title" { (title) }
|
||||||
|
}
|
||||||
|
div class="pt-block__body" { (block_body) }
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
let id = cx.required_id::<Block>(self.id());
|
PrepareMarkup::None
|
||||||
PrepareMarkup::With(html! {
|
|
||||||
div id=(id) class=[self.classes().get()] {
|
|
||||||
@if let Some(title) = self.title().using(cx.langid()) {
|
|
||||||
h2 class="block-title" { (title) }
|
|
||||||
}
|
|
||||||
div class="block-body" {
|
|
||||||
(self.components().render(cx))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue