Skip to content

Instantly share code, notes, and snippets.

@alandipert
Created November 12, 2015 14:10
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 alandipert/bd98d6d48f58f8f165a0 to your computer and use it in GitHub Desktop.
Save alandipert/bd98d6d48f58f8f165a0 to your computer and use it in GitHub Desktop.
(page "index.html")
(def current-route (route-cell))
(cell= (println current-route))
(defmethod do! :set-class
[elem _ class-name]
(.attr (js/jQuery elem) "class" class-name))
(defelem smart-a [attrs kids]
(let [class (cell= (if (= (:href attrs) current-route)
"active"
"inactive"))]
(cell= (println class))
(a (assoc attrs :set-class class)
kids)))
(html
(head
(link :href "app.css" :rel "stylesheet"))
(body
(ul
(li
(smart-a :href "#/foo/bar" "Link to #/foo/bar"))
(li
(smart-a :href "#/" "Link to /")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment