diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-02-18 01:07:50 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-02-18 01:07:50 +0100 |
| commit | 05ec0f993b4a1b8481e494ee16285d23f000872f (patch) | |
| tree | bad1ea092025213173e66a3a88cf2c8d3f4ca3a3 /src/eval | |
| parent | acae6e2a54f11b27bae343a15d9eff952323fe28 (diff) | |
Headers and footers
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) |
