我正在尝试创建生成包含一些数据的表的模板。数据来自 msh-contents 中定义的映射。
(require '[net.cgrand.enlive-html :as html])
(def msh-contents {:title "Events mashup",
:data-content [{:title "ICTM Study Group ",
:url "http://some-url.com"}
{:title "Volodja Balzalorsky - Hinko Haas",
:url "http://some- other-url.com"}
]})
;; define snippets based on some divs in the template
(html/defsnippet header-cell (template-div) [:div.Heading :div.Cell][value]
(html/content value))
(html/defsnippet value-cell (template-div) [:div.Row :div.Cell] [value]
(html/content value))
;; define a template
(html/deftemplate mshp "index.html" [cont]
[:div.Heading]
(html/content (for [c (keys (first (:data-content cont)))] (header-cell (name c))))
[:div.Row]
(html/content (map #(value-cell %) (for[e (:data-content cont)] (vals e)))))
所以,在 REPL 中调用模板
(mshp msh-contents)
产生错误:IllegalArgumentException ArityException 传递给的 args (0) 数量错误:PersistentArrayMap clojure.lang.AFn.throwArity (AFn.java:437),这可能是因为片段产生了 LazySeq。