Last active
May 30, 2019 18:40
-
-
Save andreortiz82/f841a9d231f75d5c1a6ed182ff51aa2f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
;; 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