Commits

kumarshantanu  committed bf6e493

stringify all keys in fill-view!

  • Participants
  • Parent commits 21d1910

Comments (0)

Files changed (2)

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

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

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

 (ns org.bituf.clj-stringtemplate.internal)
 
+
+(defn stringify [any]
+  (if (keyword? any)
+    (name any)
+    (str any)))
+
+
 (declare kv-to-sv)
 
+
 (defn scan-kv-to-sv
   "Scans a collection and turns any contained map within from kv to sv"
   [coll]
             %))
     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}"
         k (keys m)
         v (vals m)]
     (zipmap
-      (map #(if (keyword? %)
-              (name %)
-              (str %))
-        k)
+      (map stringify k)
       (scan-kv-to-sv v))))