Fork me on GitHub
#clojurescript
<
2021-06-10
>
T M00:06:14

excuse me. i want to use bootstrap. is there any bootstrap for cljs library i can use? thanks

henryw37410:06:27

I don't think you'd need a library around bootstrap?

max minoS04:06:37

I have a .json file in the same directory as my clojurescript file, how do I import that .json and convert it into a clojure object?

djblue05:06:45

I would write a clojure macro which can load and parse the json.

max minoS05:06:16

should I just convert the entire json into a clojure object

max minoS05:06:35

i was initially going to put the JSONs as a gist that I can GET using cljs-ajax (which I think can parse the JSON), but then I thought that it's probably even better if i can just import the JSON in the same source directory

djblue05:06:25

You can, although the macros still needs to return valid clojurescript code. It might be easier to return (js->clj (.parse js/JSON "..."))

max minoS05:06:02

how do I import the JSON file in the first place?

djblue05:06:49

(defmacro load-json [file]
  `(js->clj (.parse js/JSON ~(slurp file))))

djblue05:06:01

☝️ is a more complete solution

djblue05:06:23

But the idea is that you use the jvm to load the file as a string and parse the json in the javascript runtime via interop

🙏 3
djblue05:06:45

You can also leverage if you want to load a file from the classpath, like in a jar 👌

djblue05:06:35

(defmacro load-resource-json [file]
  `(js->clj (.parse js/JSON ~(slurp ( file)))))

weihua05:06:01

if you're using shadow-cljs, you can just use shadow.resource/inline without creating your own slurp and worrying about compilation reload stuff yourself https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745

👀 2
Brice Ruth22:06:24

qq: I'd like to use speclj in a cljs project ... is it possible to just use node as the test runner, instead of phantomjs? Is there a better alternative for BDD/TDD style tests in cljs these days, since speclj saw it's last release in 2016, it seems?