I want to create a template with Clojure's Enlive for a "table" like html page, that should have a header and rows. I want to populate this "table" with data that comes from this map. Basicaly I want to populate header with keys, and cells with vals from each of the maps that come from :event-data key.
(def dummy-content
{:title "Events Mashup"
:event-data [{ :event-name "event name 1"
:performer "performer 1"
:date "date 1"
:start-time "start time 1"
:end-time "end time 1"}
{:event-name "event name 2"
:performer "performer 2"
:date "date 2"
:start-time "start time 2"
:end-time "end time 2"}]})
My snippets and template look like this:
(defsnippet header-cell "index.html" [:.psdg-top-cell] [value] [:.psdg-top-cell]
(defsnippet value-cell "index.html" [:.psdg-right] [value] [:.psdg-right]
(deftemplate mshp "index.html" [content]
[:.psdg-top] (append (for [c (keys content)] (header-cell c)))
[:.psdg-right] (append (for [v (vals content)] (value-cell v))))
And index.html has these tags, that are rellevant for this template.
<div id="psdg-top">
<div class="psdg-top-cell" style="width:129px; text-align:left; padding- left:24px;">Summary</div>
<div class="psdg-top-cell">Website.com</div>
</div>
<div class="psdg-right">10 000</div>
When I call the template I get this error:
=> (mshp (:event-data dummy-content))
ClassCastException clojure.lang.PersistentHashMap cannot be cast to java.util.Map$Entry clojure.lang.APersistentMap$ValSeq.first (APersistentMap.java:183) What am I doing wrong?