Arcade.Html
Types
Functions
fn escape(s : String) : String needs () do let a = String.replace_all(s, "&", "&") let b = String.replace_all(a, "<", "<") let c = String.replace_all(b, ">", ">") let d = String.replace_all(c, "\"", """) String.replace_all(d, "'", "'") end
pfn prop_into(acc : List(String), p : Prop) : List(String) needs () do match p do Prop(name, value) -> Cons(" " ++ name ++ "=\"" ++ escape(value) ++ "\"", acc) end end
pfn render_into(acc : List(String), h : Html) : List(String) needs () do match h do Words(s) -> Cons(escape(s), acc) Tag(name, props, kids) -> do let opened = Cons(">", List.fold_left(props, Cons("<" ++ name, acc), prop_into)) let inner = List.fold_left(kids, opened, render_into) Cons("</" ++ name ++ ">", inner) end end end