diff --git a/edn/src/edn_view.rs b/edn/src/edn_view.rs index 488b8f3e..170bef06 100644 --- a/edn/src/edn_view.rs +++ b/edn/src/edn_view.rs @@ -35,11 +35,24 @@ impl + Send + Sync> Content for EdnView { fn content (&self) -> impl Render { 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..]) {