Anonymous avatar Anonymous committed 42cef97

deep-transform all values

Comments (0)

Files changed (2)

src/main/clj/org/bituf/clj_stringtemplate.clj

   ;;;
   ;; Fill template with key and value
   ([^StringTemplate template k v]
-    (.setAttribute template (stringify k) v)
+    (.setAttribute template (stringify k) (each-kv-to-sv v))
     template)
   ;;;
   ;; Fill template with key/value from map

src/main/clj/org/bituf/clj_stringtemplate/internal.clj

 
 
 (declare kv-to-sv)
+(declare scan-kv-to-sv)
+
+
+(defn each-kv-to-sv "If element is a collection type, do deep transformation"
+  [each]
+  (if (map? each)
+    (kv-to-sv each)
+    (if (or (vector? each) (list? each) (seq? each) (set? each))
+      (scan-kv-to-sv each)
+      each)))
 
 
 (defn scan-kv-to-sv
   "Scans a collection and turns any contained map within from kv to sv"
   [coll]
-  (map #(if (map? %)
-          (kv-to-sv %)
-          (if (or (vector? %) (list? %) (seq? %) (set? %))
-            (scan-kv-to-sv %)
-            %))
-    coll))
+  (map each-kv-to-sv coll))
 
 
 (defn kv-to-sv
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.