Fork me on GitHub
#beginners
<
2016-09-06
>
martinklepsch21:09:45

@slester are you familiar with macros to some degree?

slester21:09:57

kinda? 😄

slester21:09:14

basically a helper function?

martinklepsch21:09:27

No idea if this snippet will work but essentially you'd read your file in Clojure and put it's contents into your cljs file:

(defmacro inline-json [file-path]
  `(js/JSON.parse ~(slurp file-path)))

martinklepsch21:09:40

does that basic idea make sense @slester ?

slester21:09:55

yep! it's saying slurp is undefined, but I can just (def names (inline-json "names.json")) from there?

martinklepsch22:09:54

@slester do you know that macros for Clojurescript need to be defined in Clojure files?

martinklepsch22:09:30

I gotta go, much success 👍

slester22:09:32

like in a cljc file?