Created
August 29, 2016 19:11
-
-
Save alandipert/9f5a64858eb244dec78d2a9238ad0152 to your computer and use it in GitHub Desktop.
toggle visibility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(page "index.html") | |
(defc people | |
[{:name "Alan" | |
:age 32 | |
:nickname "Coolpants"} | |
{:name "Felix the Cat" | |
:age 8 | |
:nickname "Cuddles"} | |
{:name "Steve" | |
:age 11 | |
:nickname "Psycho"}]) | |
(html | |
(head) | |
(body | |
(button :click #(swap! people conj {:name (str (gensym)) :age (rand-int 100) :nickname (gensym)}) | |
"Add") | |
(button :click #(swap! people pop) | |
"Pop") | |
(ul | |
(for-tpl [person people] | |
(let [details? (cell (do (println "made a cell") false))] | |
(li :click #(swap! details? not) | |
(span (text "Name: ~(:name person)")) | |
(pre :toggle details? (cell= (pr-str person))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works like a charm!