diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/library/layout.rs | 20 | ||||
| -rw-r--r-- | src/library/mod.rs | 2 |
2 files changed, 22 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); diff --git a/src/library/mod.rs b/src/library/mod.rs index 5f0430b2..92ee9faa 100644 --- a/src/library/mod.rs +++ b/src/library/mod.rs @@ -41,6 +41,8 @@ pub fn new() -> Scope { std.def_func("h", h); std.def_func("v", v); std.def_func("align", align); + std.def_func("box", boxed); + std.def_func("block", block); std.def_func("pad", pad); std.def_func("stack", stack); std.def_func("grid", grid); |
