Skip to content

Instantly share code, notes, and snippets.

@augustl
Created January 2, 2012 23:42
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 augustl/1552654 to your computer and use it in GitHub Desktop.
Save augustl/1552654 to your computer and use it in GitHub Desktop.
(def main-menu-links
[{:text "Home" :url "/" :key :home}
{:text "Documentation" :url "/docs" :key :docs}
{:text "Community" :url "/community" :key :community}])
(defn build-main-menu-item [{:keys [text url key]} active-menu]
[:li (link-to
(if (= key active-menu) {:class "active"} {})
url
text)])
(defn build-main-menu [active-menu]
(map #(build-main-menu-item % active-menu) main-menu-links))
; Equivalent of:
; (map (fn [index] (build-main-menu-item index active-menu)) main-menu-links))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment