Create img tags with Noir from list

I have a list of photo links and want to generate img tags using clojure and noir.

This is where I get links:

(def photos
(->> (get-in result ["photoset" "photo"]) (map #(str "http://farm"(get % "farm")
".staticflickr.com/"(get % "server")"/"(get % "id")"_"(get % "secret")"_b.jpg"))))

      

Result:

(http://farm9.staticflickr.com/8087/8455893107_1a3236df06_b.jpg http://farm9.staticflickr.com/8235/8469482476_4c1bf59214_b.jpg)

      

And then I try to create img tags from this list:

(defpage "/" []
 (mylayout/layout
 (doseq [e photos] (prn e))
 ))

      

(calls (defpartial layout [& content] ...)

I'm trying to get the following output for each link for a noir site:

[:img {:src "url"}]

      

I tested this one but without success:

(doseq [e photos] ([:img {:src e}]))

      

How do I pass links to the layout so that it generates img tags?

Thank!

+3


source to share


1 answer


Any of these should work:

(map #(vector :img {:src %}) photos)

(for [url photos]
  [:img {:src url}])

      



Edit: As mentioned by Chuck , doseq

intended for side effects. You want to "collect" the results and send them to the template. To do this, you need to use a list comprehension, for example for

or just map

by your collection.

I hate rain on your parade, but so you know noir is out of date

+4


source







All Articles