/
sample.cljs
33 lines (27 loc) · 918 Bytes
/
sample.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(ns sample
(:use-macros [crate.def-macros :only [defpartial]]
[cljsbinding.crate-macros :only [insert-content]] )
(:require [cljsbinding :as binding]
[cljsbinding.crate :as bind-crate]
[crate.core :as crate]
)
(:use [jayq.core :only [$ attr val change show hide append remove]])
)
(def testatom (atom {:name "mr t" :phone "123456"}))
(defn gen-form-input [atm k]
[:div
[:label (name k)]
(bind-crate/add-binding [:input {:id (name k)}] atm)]
)
(defn gen-form [atm]
(map (partial gen-form-input atm) (keys @atm)))
(defn phone-number [] (str "Tel: " (:phone @testatom)))
(defn gen-content []
(insert-content "placeholder"
[:div
(gen-form testatom)
[:div "You can reach "
(bind-crate/add-binding [:span {:id :name}] testatom)
" on "
(bind-crate/add-binding [:span] {:text phone-number})]
]))