aboutsummaryrefslogtreecommitdiffstats
path: root/src/view.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/view.rs')
-rw-r--r--src/view.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/view.rs b/src/view.rs
index b7bab6c..bd4b8f5 100644
--- a/src/view.rs
+++ b/src/view.rs
@@ -17,8 +17,9 @@ use crate::scratch::Scratch;
/// would be, the others as they are.
pub type Entries<'a> = BTreeMap<&'a str, &'a Content>;
-/// Renders the view `name` from `entries` into scratch below `scratch`; nothing if it
-/// is an entry's own and that entry isn't there.
+/// Renders the view `name` from `entries` into scratch below `scratch`; nothing if a
+/// required slot it is made from is unfilled, or it is an entry's own and that entry
+/// isn't there.
pub fn render(
schema: &Schema,
name: &str,
@@ -31,6 +32,13 @@ pub fn render(
.get(address.channel.as_str())
.and_then(|content| content.get(&address.slot))
};
+ // A view made from a required slot that is unfilled isn't there (docs/design.md,
+ // section 7).
+ if view.from.iter().any(|address| {
+ schema.slot(address).is_some_and(|slot| slot.required) && entry(address).is_none()
+ }) {
+ return Ok(None);
+ }
match &view.renderer {
None => {
let address = &view.from[0];