hodur-engine icon indicating copy to clipboard operation
hodur-engine copied to clipboard

Fix `init-path` for ClojureScript

Open luchiniatwork opened this issue 5 years ago • 1 comments

This will be particularly useful for plugins such as the Visualizer for now.

The trick might involve something along the lines of a macro somewhat like this:

(defmacro inline-resource [resource-path]
  (slurp (io/resource resource-path)))

Combined with ClojureScript's reader, i.e:

(cljs.reader/read-string
  (inline-all-edns "schemas/editorial.edn"))

luchiniatwork avatar Nov 14 '18 14:11 luchiniatwork

You can skip the read-string and inline the edn itself. You can change init-path to a macro

(defmacro init-path [path & others]
  (let [paths (-> others flatten (conj path) flatten)
        data (->> paths
                  schema-files
                  slurp-files
                  vec)]
   `(apply init-schema (quote ~data))))

pkpkpk avatar Nov 15 '18 20:11 pkpkpk