~subsetpark/bagatto

4fc04b3afee0f496217a3243a75f75d51d5b64f1 — Zach Smith 3 days ago 2521a3c master
Add render some
1 files changed, 26 insertions(+), 0 deletions(-)

M src/generators.janet
M src/generators.janet => src/generators.janet +26 -0
@@ 34,6 34,22 @@
          (array/push res [:write path contents]))))
    (:send parent [:res spec-name res])))

(defn- render-some-generator
  [data spec-name site-selector path-generator renderer]
  (fn [parent]
    (set-cxt! spec-name)

    (threads/print "Generating path for " spec-name "...")
    (def res @[])

    (let [item (data site-selector)]
      (unless (and item (item :path))
        (error/copy-error spec-name site-selector item))
      (let [path (apply-path path-generator [data item] :di)
            contents (apply-renderer renderer [data item] :di)]
        (array/push res [:write path contents])))
    (:send parent [:res spec-name res])))

(defn- render-generator
  [data spec-name path-generator renderer]
  (fn [parent]


@@ 64,6 80,7 @@
          (array/push res [:copy from to]))))
    (:send parent [:res spec-name res])))


(defn- copy-some-generator
  [data spec-name site-selector path-generator]
  (fn [parent]


@@ 103,6 120,15 @@
                           site-selector
                           path-generator)

      {:some site-selector
       :dest path-generator
       :out renderer}
      (render-some-generator data
                             spec-name
                             site-selector
                             path-generator
                             renderer)

      {:dest path-generator
       :out renderer}
      (render-generator data