 
 (defonce template-cache (atom {}))
 
+(def ^:dynamic *fns* {"=>" (fn [source dest]
+                             (mapv #(assoc state dest %)
+                                   source))
+                      "identity" identity
+                      "vector" vector
+                      "hashmap" hash-map
+                      "set" set
+                      "resolve-symbol" (fn [state symb] (or (get *fns* symb)
+                                                            (get state symb "[empty]")))
+                      "template" #(render-template % %2)})
+
 (defn render-template
   [tname state & {:keys [fns]}]
-  (dbg2 "render-template state" state)
-  (sab/html  (cached-template->hiccup tname
-                                      (update-in state [:fns] merge fns))))
+  (binding [*fns* (merge *fns* fns)]
+    (sab/html (cached-template->hiccup tname
+                                       state))))
 
 (defn has-all-keys? [m keys]
   (apply = (map count [keys (select-keys m keys)])))


(defn eval-om-if-expr
  [x state]
  (dbg2 "om-if x = " x)
  (dbg2 "om-if state = " state)
  (get state (apply str (mapcat second x))))

(defn html->template

  [l v]
  (.log js/console l)
  (.log js/console (clj->js v))
  (.log js/console v)
  v)

(defn dbg2->
