Question

If I have a vector name-lst as ["John" "Mary" "Watson" "James"],

and I want to diplay them as list items, how do I do that using hiccup ?

something like

[:ul 
  (for [name name-list]
    [:li name])]

will return a list of [:li ] in between [:ul ] instead of just repeating. There must be something better. I am relatively new to hiccup, I searched but couldn't find anything.

Was it helpful?

Solution

Once you feed the data structure to Hiccup you should get the expected result:

(require '[hiccup.core :refer [html]])

(def names
  ["John" "Mary" "Watson" "James"])

(html [:ul 
       (for [name names]
         [:li name])])
;=> "<ul><li>John</li><li>Mary</li><li>Watson</li><li>James</li></ul>"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top