Skip to content

Instantly share code, notes, and snippets.

@andreortiz82
Last active May 30, 2019 18:40
Show Gist options
  • Save andreortiz82/f841a9d231f75d5c1a6ed182ff51aa2f to your computer and use it in GitHub Desktop.
Save andreortiz82/f841a9d231f75d5c1a6ed182ff51aa2f to your computer and use it in GitHub Desktop.
;; Basic boilerplate helpers for the common man.
;; Defining data
;; Vector is a collection
;; With Vectors, I can generate lists in my UI
(def my-vector [])
;; Maps are a Key / Value object
(def my-map {:name "Julian" :location "PDX"})
;; Example of a collection
;; This is a Vector of Maps
(def my-collection [{:name "Larry"}, {:name "Mo"}, {:name "Curly"}])
;; Helper number 1: Creating a list
(defn my-ui-list-function
"This method creates a list based on the collection"
[collection]
[:ul
(map-indexed
(fn [index item]
[:li {:key (:name item)}
(:name item)])
collection)])
;; Call the function
(my-ui-list-function my-collection)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment