nbb 2024-09-02

Is it possible to have a nbb script get a var by name from another cljs file and use then it? For example:

(ns entry)

(def data {:name "James"})

(def home-page [] [:h1 "Welcome"])
and then an nbb script which would do something like:
(p/let [result-str (nbb/slurp "path/to/entry.cljs") 
        data       (get-var result-str "data")]
  data)

yes, you can use a combination of load-string and resolve

(nbb.core/load-string "(ns foo) (defn foo [])")

use this within p/let

How would I reference a specific var? For example:

(nbb.core/load-string "(ns foo) (def data {:count 1}) (defn foo [])")
load-string would return #'foo/foo , yes? How might I use #'foo/data ?

(resolve 'foo/data)

👍 1