문제

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.

도움이 되었습니까?

해결책

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>"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top