diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-06-26 15:47:37 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-06-26 15:47:37 +0200 |
| commit | d53c933e4d56e6c0484d81814779ddb1597ee032 (patch) | |
| tree | 493aa2f8397a26b11a1137d2882994686b5ac7de /src/library/layout.rs | |
| parent | 784018124d13a4cfb050b8bf1fecd283cdc309db (diff) | |
Add box and block functions
Diffstat (limited to 'src/library/layout.rs')
| -rw-r--r-- | src/library/layout.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/library/layout.rs b/src/library/layout.rs index 10389779..27b2e743 100644 --- a/src/library/layout.rs +++ b/src/library/layout.rs @@ -210,6 +210,26 @@ castable! { AlignValue: "alignment", } +/// ´box`: Place content in a rectangular box. +pub fn boxed(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { + let width = args.named(ctx, "width"); + let height = args.named(ctx, "height"); + let body = args.eat(ctx).unwrap_or_default(); + Value::template(move |ctx| { + let child = ctx.exec_template_stack(&body).into(); + ctx.push_into_par(FixedNode { width, height, child }); + }) +} + +/// block`: Place content in a block. +pub fn block(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { + let body = args.eat(ctx).unwrap_or_default(); + Value::template(move |ctx| { + let block = ctx.exec_template_stack(&body); + ctx.push_into_stack(block); + }) +} + /// `pad`: Pad content at the sides. pub fn pad(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { let all = args.eat(ctx); |
