From 5ac7eb3860ebd3247f6486c227e816894cb8fd91 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 11 Mar 2022 12:59:55 +0100 Subject: Rename template to content --- src/eval/array.rs | 2 +- src/eval/capture.rs | 4 +- src/eval/class.rs | 19 +- src/eval/content.rs | 581 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/eval/layout.rs | 2 +- src/eval/mod.rs | 68 +++--- src/eval/module.rs | 4 +- src/eval/ops.rs | 25 +-- src/eval/show.rs | 8 +- src/eval/styles.rs | 4 +- src/eval/template.rs | 587 --------------------------------------------------- src/eval/value.rs | 36 ++-- 12 files changed, 668 insertions(+), 672 deletions(-) create mode 100644 src/eval/content.rs delete mode 100644 src/eval/template.rs (limited to 'src/eval') diff --git a/src/eval/array.rs b/src/eval/array.rs index 7ff5fb74..294d2871 100644 --- a/src/eval/array.rs +++ b/src/eval/array.rs @@ -89,7 +89,7 @@ impl Array { a.partial_cmp(b).unwrap_or_else(|| { if result.is_ok() { result = Err(format!( - "cannot compare {} with {}", + "cannot order {} and {}", a.type_name(), b.type_name(), )); diff --git a/src/eval/capture.rs b/src/eval/capture.rs index b27aceb7..4e8d7604 100644 --- a/src/eval/capture.rs +++ b/src/eval/capture.rs @@ -49,8 +49,8 @@ impl<'a> CapturesVisitor<'a> { // through the expressions that contain them). Some(Expr::Ident(ident)) => self.capture(ident), - // Blocks and templates create a scope. - Some(Expr::Code(_) | Expr::Template(_)) => { + // Code and content blocks create a scope. + Some(Expr::Code(_) | Expr::Content(_)) => { self.internal.enter(); for child in node.children() { self.visit(child); diff --git a/src/eval/class.rs b/src/eval/class.rs index 2cced74d..05191667 100644 --- a/src/eval/class.rs +++ b/src/eval/class.rs @@ -2,24 +2,25 @@ use std::any::TypeId; use std::fmt::{self, Debug, Formatter, Write}; use std::hash::{Hash, Hasher}; -use super::{Args, Func, StyleMap, Template, Value}; +use super::{Args, Content, Func, StyleMap, Value}; use crate::diag::TypResult; use crate::Context; /// A class of nodes. /// /// You can [construct] an instance of a class in Typst code by invoking the -/// class as a callable. This always produces a template value, but not +/// class as a callable. This always produces a content value, but not /// necessarily a simple inline or block node. For example, the `text` /// constructor does not actually create a [`TextNode`]. Instead it applies -/// styling to whatever node you pass in and returns it structurally unchanged. +/// styling to whatever content you pass in and returns it structurally +/// unchanged. /// /// The arguments you can pass to a class constructor fall into two categories: /// Data that is inherent to the instance (e.g. the text/content of a heading) /// and style properties (e.g. the fill color of a heading). As the latter are /// often shared by many instances throughout a document, they can also be /// conveniently configured through class's [`set`] rule. Then, they apply to -/// all nodes that are instantiated into the template where the `set` was +/// all nodes that are instantiated into the content block where the `set` was /// executed. /// /// ```typst @@ -55,8 +56,8 @@ impl Class { construct: |ctx, args| { let mut styles = StyleMap::new(); T::set(args, &mut styles)?; - let template = T::construct(ctx, args)?; - Ok(Value::Template(template.styled_with_map(styles.scoped()))) + let content = T::construct(ctx, args)?; + Ok(Value::Content(content.styled_with_map(styles.scoped()))) }, set: T::set, } @@ -80,8 +81,8 @@ impl Class { /// Construct an instance of the class. /// /// This parses both property and data arguments (in this order), styles the - /// template constructed from the data with the style properties and wraps - /// it in a value. + /// content constructed from the data with the style properties and wraps it + /// in a value. pub fn construct(&self, ctx: &mut Context, mut args: Args) -> TypResult { let value = (self.construct)(ctx, &mut args)?; args.finish()?; @@ -126,7 +127,7 @@ pub trait Construct { /// /// This is passed only the arguments that remain after execution of the /// class's set rule. - fn construct(ctx: &mut Context, args: &mut Args) -> TypResult