macro | since v0.0-1535 | clojure.core/with-out-str | Edit |
(with-out-str & body)
Evaluates exprs in a context in which *print-fn* is bound to .append on a fresh StringBuffer. Returns the string created by any nested printing calls.
(core/defmacro with-out-str
[& body]
`(let [sb# (goog.string/StringBuffer.)]
(binding [cljs.core/*print-newline* true
cljs.core/*print-fn* (fn [x#] (.append sb# x#))]
~@body)
(cljs.core/str sb#)))