diff options
Diffstat (limited to 'src/eval')
| -rw-r--r-- | src/eval/func.rs | 15 | ||||
| -rw-r--r-- | src/eval/template.rs | 6 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/eval/func.rs b/src/eval/func.rs index 9a8a9c94..128509f8 100644 --- a/src/eval/func.rs +++ b/src/eval/func.rs @@ -167,6 +167,21 @@ pub struct Arg { } impl Args { + /// Create positional arguments from a span and values. + pub fn from_values(span: Span, values: impl IntoIterator<Item = Value>) -> Self { + Self { + span, + items: values + .into_iter() + .map(|value| Arg { + span, + name: None, + value: Spanned::new(value, span), + }) + .collect(), + } + } + /// Consume and cast the first positional argument. /// /// Returns a `missing argument: {what}` error if no positional argument is diff --git a/src/eval/template.rs b/src/eval/template.rs index 68974452..1f1544e6 100644 --- a/src/eval/template.rs +++ b/src/eval/template.rs @@ -169,7 +169,7 @@ impl Template { } /// Layout this template into a collection of pages. - pub fn layout(&self, vm: &mut Vm) -> TypResult<Vec<Arc<Frame>>> { + pub fn layout_pages(&self, vm: &mut Vm) -> TypResult<Vec<Arc<Frame>>> { let sya = Arena::new(); let tpa = Arena::new(); @@ -180,8 +180,10 @@ impl Template { let mut frames = vec![]; let (pages, shared) = builder.pages.unwrap().finish(); + for (page, map) in pages.iter() { - frames.extend(page.layout(vm, map.chain(&shared))?); + let number = 1 + frames.len(); + frames.extend(page.layout(vm, number, map.chain(&shared))?); } Ok(frames) |
