summaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-01-30 12:09:26 +0100
committerLaurenz <laurmaedje@gmail.com>2021-01-30 12:09:26 +0100
commit89eb8bae49edb71d9a9279a2210bb1ccaf4dd707 (patch)
tree160b1a2ff41b5bba8a58f882df9d10c9eb036cf2 /src/eval
parentac24075469f171fe83a976b9a97b9b1ea078a7e3 (diff)
New syntax 💎
- Everything everywhere! - Blocks with curly braces: {} - Templates with brackets: [] - Function templates with hashtag: `#[f]` - Headings with equals sign: `= Introduction`
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/value.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/eval/value.rs b/src/eval/value.rs
index 6e838f6c..860c0634 100644
--- a/src/eval/value.rs
+++ b/src/eval/value.rs
@@ -8,7 +8,7 @@ use super::{Args, Eval, EvalContext};
use crate::color::Color;
use crate::geom::{Angle, Length, Linear, Relative};
use crate::pretty::{pretty, Pretty, Printer};
-use crate::syntax::{Spanned, Tree, WithSpan};
+use crate::syntax::{pretty_template, Spanned, Tree, WithSpan};
/// A computational value.
#[derive(Debug, Clone, PartialEq)]
@@ -121,11 +121,7 @@ impl Pretty for Value {
Value::Str(v) => write!(p, "{:?}", v).unwrap(),
Value::Array(v) => v.pretty(p),
Value::Dict(v) => v.pretty(p),
- Value::Template(v) => {
- p.push_str("[");
- v.pretty(p);
- p.push_str("]");
- }
+ Value::Template(v) => pretty_template(v, p),
Value::Func(v) => v.pretty(p),
Value::Any(v) => v.pretty(p),
Value::Error => p.push_str("(error)"),
@@ -537,8 +533,8 @@ mod tests {
// Dictionary.
let mut dict = BTreeMap::new();
dict.insert("one".into(), Value::Int(1));
- dict.insert("two".into(), Value::Template(parse("[f]").output));
+ dict.insert("two".into(), Value::Template(parse("#[f]").output));
test_pretty(BTreeMap::new(), "(:)");
- test_pretty(dict, "(one: 1, two: [[f]])");
+ test_pretty(dict, "(one: 1, two: #[f])");
}
}