Skip to content

Instantly share code, notes, and snippets.

@haywoood
Created October 16, 2013 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haywoood/7015834 to your computer and use it in GitHub Desktop.
Save haywoood/7015834 to your computer and use it in GitHub Desktop.
todos...
(ns bare.core
(:require
[clojure.string :as s :refer [join]]
[cljs.core.async :as async :refer [<! >! chan timeout put!]]
[dommy.utils :as utils]
[dommy.core :as dommy])
(:use-macros
[dommy.macros :only [node sel sel1 deftemplate]])
(:require-macros [cljs.core.async.macros :as m :refer [go]]))
(def todos [{:title "dishes" :done false}
{:title "cook" :done true}])
(deftemplate checkbox-tpl [bool-val]
[:input
{:type "checkbox" :ok "dokie"}])
(deftemplate todo-tpl [todo]
[:li {:class (s/join " "
["todo"
(if (= true (todo :done))
"done")])}
(todo :title)
(checkbox-tpl (todo :done))])
(deftemplate todos-tpl [todos]
[:ul.todos-list
(map todo-tpl todos)])
(deftemplate header-tpl []
[:p "todos"])
(defn render [tpl]
(let [app (sel1 :.todos-app)]
(dommy/append! app tpl)))
(render (header-tpl))
(render (todos-tpl todos))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment