start implementing support for rendering edn keys

This commit is contained in:
🪞👃🪞 2025-01-05 11:39:46 +01:00
parent ab1301687d
commit b80f5c5c70

View file

@ -35,11 +35,24 @@ impl<E: Engine, T: EdnLayout<E> + Send + Sync> Content<E> for EdnView<E, T> {
fn content (&self) -> impl Render<E> {
use EdnItem::*;
match &self.layout {
Nil => None,
Sym(t) => Some(self.context.get_content(t.as_str())),
Nil => ().boxed(),
Sym(t) => self.context.get_content(t.as_str()).boxed(),
Key(t) => panic!("todo: add error handling to content() chain. unexpected key {t}"),
Num(n) => panic!("todo: add error handling to content() chain. unexpected num {n}"),
Exp(e) => todo!("exp {e:?}"),
Exp(e) => if let [head, tail @ ..] = e.as_slice() {
let head = &head.to_ref();
match (head, tail) {
(Key("when"), [Sym(c), Sym(a)]) => When(
self.context.get_bool(c.as_str()),
self.context.get_content(a.as_str())).boxed(),
(Key("bsp/s"), [Sym(a), Sym(b)]) => Bsp::s(
self.context.get_content(a.as_str()),
self.context.get_content(b.as_str())).boxed(),
_ => todo!("{:?} {:?}", &head, &tail)
}
} else {
panic!("todo: add error handling to content() chain. invalid expression {e:?}")
},
}
//let items = &self.layout;
//if let (Some(first), rest) = (items.get(0).map(EdnItem::to_str), &items[1..]) {