The error is occurring when you call (keys content)
, because (:event-data dummy-content)
returns a vector, and keys
won't work on a vector. You've got two options - you can either define your header columns elsewhere, or just take them from the first element in the vector, like this: (keys (first content))
.
Edit
I've had a go at replicating what you set out in the question, but fixing the errors, and you can find my efforts here: https://www.refheap.com/17659.
If you want something that has a more typical table structure, with the value cells contained in rows, you can try the following. It uses clone-for
rather than a combination of append
and for
, and uses nth-of-type
to just return the first "psdg-top-cell" (otherwise there would be twice as many)
(def template
(html-snippet
"<div id=\"psdg-top\">
<div class=\"psdg-top-cell\">Summary</div>
<div class=\"psdg-top-cell\">Website.com</div>
</div>
<div class=\"psdg-right\">10 000</div>"))
(defsnippet header-row template [[:.psdg-top-cell (nth-of-type 1)] ] [headers]
(clone-for [h headers]
(content h)))
(defsnippet value-row template [:.psdg-right] [values]
(clone-for [v values]
(content v)))
(deftemplate mshp template [events]
[:#psdg-top] (content (header-row (map name (keys (first events)))))
[:.psdg-right] (clone-for [e events]
(do->
(wrap :div {:class "psdg-row"})
(content (value-row (vals e))))))