So far I've managed to figure out how to duplicate a div with clone-for, but I haven't found a function for conditionally applying a transformation, while inside the deftemplate macro.
(deftemplate threads "thread.html" [xs]
[:div.entry] ;hook to a div
(clone-for [x xs] ;for each in the array passed in
(if (contains? x :picture) ;if picture in object
([:div.entry :> :img] (set-attr :src (:picture x))) ;show picture
([:div.entry] (set-attr :style "display:none;"))) ;else hide element
;do more things here
))
(threads [{:picture 'link goes here'},{},...])
returns
java.lang.IllegalArgumentException: Key must be integer
I'm wondering if anyone more experienced with enlive could help? I'm not sure what the following should propely be written as.
(if (contains? x :picture) ;if picture in object
([:div.entry :> :img] (set-attr :src (:picture x))) ;show picture
([:div.entry] (set-attr :style "display:none;"))) ;else hide element
EDIT: I've commented and cut out code not related to my question below, at the suggestion of Alan.