This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-06
Channels
- # announcements (1)
- # babashka (117)
- # bangalore-clj (4)
- # beginners (52)
- # calva (3)
- # cider (1)
- # circleci (1)
- # cljsrn (1)
- # clojure (5)
- # clojure-italy (1)
- # clojurescript (5)
- # conjure (23)
- # datahike (32)
- # datomic (12)
- # fulcro (5)
- # graalvm (6)
- # jobs (1)
- # joker (2)
- # kaocha (1)
- # livestream (1)
- # malli (5)
- # meander (4)
- # off-topic (14)
- # pathom (6)
- # re-frame (7)
- # releases (3)
- # reveal (15)
- # sci (1)
- # shadow-cljs (22)
- # spacemacs (7)
m/unparse
and m/unparser
landed in master! parse + unparse with hiccup:
(def Hiccup
[:schema
{:registry {"hiccup" [:or*
[:node [:cat*
[:name keyword?]
[:props [:? [:map-of keyword? any?]]]
[:children [:* [:schema [:ref "hiccup"]]]]]]
[:primitive [:or*
[:nil nil?]
[:boolean boolean?]
[:number number?]
[:text string?]]]]}}
"hiccup"])
(m/parse
Hiccup
[:div {:class [:foo :bar]}
[:p "Hello, world of data"]])
;[:node
; {:name :div,
; :props {:class [:foo :bar]},
; :children [[:node
; {:name :p
; :props nil
; :children [[:primitive [:text "Hello, world of data"]]]}]]}]
(->> [:div {:class [:foo :bar]}
[:p "Hello, world of data"]]
(m/parse Hiccup)
(m/unparse Hiccup))
;[:div {:class [:foo :bar]}
; [:p "Hello, world of data"]]
yes, same as s/confom
and s/unform
. At the moment, there are no property-based custom parsers/unparsers that a user could add (like custom property based transformers) and in case of error, just ::m/invalid
is returned. I think we can later combine -parse
, -unparse
and -explain
implementations together, so that one can see partially parsed results and get more details when parsing/unparsing fails (same output as in -explain
).