summaryrefslogtreecommitdiff
path: root/src/library/layout/hide.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/layout/hide.rs')
-rw-r--r--src/library/layout/hide.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/library/layout/hide.rs b/src/library/layout/hide.rs
new file mode 100644
index 00000000..861a1208
--- /dev/null
+++ b/src/library/layout/hide.rs
@@ -0,0 +1,30 @@
+use crate::library::prelude::*;
+
+/// Hide a node without affecting layout.
+#[derive(Debug, Hash)]
+pub struct HideNode(pub LayoutNode);
+
+#[class]
+impl HideNode {
+ fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> {
+ Ok(Template::inline(Self(args.expect("body")?)))
+ }
+}
+
+impl Layout for HideNode {
+ fn layout(
+ &self,
+ ctx: &mut Context,
+ regions: &Regions,
+ styles: StyleChain,
+ ) -> TypResult<Vec<Arc<Frame>>> {
+ let mut frames = self.0.layout(ctx, regions, styles)?;
+
+ // Clear the frames.
+ for frame in &mut frames {
+ *frame = Arc::new(Frame { elements: vec![], ..**frame });
+ }
+
+ Ok(frames)
+ }
+}