I trying a macro from https://clojuredocs.org/clojure.core/macroexpand
(macroexpand '(-> c (+ 3) (* 2)))
but got this in ClojureScript:
(js* "(~{} * ~{})" (+ c 3) 2)
What does ~{}
mean here?
I trying a macro from https://clojuredocs.org/clojure.core/macroexpand
(macroexpand '(-> c (+ 3) (* 2)))
but got this in ClojureScript:
(js* "(~{} * ~{})" (+ c 3) 2)
What does ~{}
mean here?
js*
is a special form that’s internal to the ClojureScript compiler, it directly outputs raw JavaScript. The ~{}
is a placeholder, you can give js*
extra arguments, and they will be filled in in the string
(js* "alert(~{})" "ok la")
Is that documented somewhere?
Not really, it’s an internal thing, but something you should use directly.