Commits

kumarshantanu  committed 21d1910

implement deep-transformation in kv-to-sv

  • Participants
  • Parent commits 543c719

Comments (0)

Files changed (1)

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

 (ns org.bituf.clj-stringtemplate.internal)
 
+(declare kv-to-sv)
+
+(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))
+
 (defn kv-to-sv
   "Transforms keyword-value map {:a 10 :b 20 :c 30}
    to string-value map {\"a\" 10 \"b\" 20 \"c\" 30}"
   (let [m (into {} mp)
         k (keys m)
         v (vals m)]
-    (zipmap (map #(if (keyword? %) (name %)
-                    (str %)) k) v)))
+    (zipmap
+      (map #(if (keyword? %)
+              (name %)
+              (str %))
+        k)
+      (scan-kv-to-sv v))))