excuse me. i want to use bootstrap. is there any bootstrap for cljs library i can use? thanks
I don't think you'd need a library around bootstrap?
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?
I would write a clojure macro which can load and parse the json.
should I just convert the entire json into a clojure object
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
You can, although the macros still needs to return valid clojurescript code. It might be easier to return (js->clj (.parse js/JSON "..."))
how do I import the JSON file in the first place?
(defmacro load-json [file]
`(js->clj (.parse js/JSON ~(slurp file))))
☝️ is a more complete solution
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
You can also leverage <http://clojure.java.io/resource|clojure.java.io/resource>
if you want to load a file from the classpath, like in a jar 👌
(defmacro load-resource-json [file]
`(js->clj (.parse js/JSON ~(slurp (<http://clojure.java.io/resource|clojure.java.io/resource> file)))))
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
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?