Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pretty print to a string in ClojureScript?

How does one use cljs.pprint to return a string?

(cljs.pprint/pprint '(foo bar))

Would like this to return a string, rather than have a side effect of printing it.

Similar to this question, but for CLJS, not CLJ.

How can I pretty print a PersistentHashMap in Clojure to a string?

like image 677
elliot42 Avatar asked Aug 19 '15 23:08

elliot42


1 Answers

This should work:

(with-out-str (cljs.pprint/pprint '(foo bar)))
like image 193
ClojureMostly Avatar answered Nov 05 '22 06:11

ClojureMostly