A somewhat related problem within all this:
In the following code, the recursive call of comments-rendition-recur
leads to the compile-time error
"java.lang.Exception: Unable to resolve symbol: comments-rendition-recur
in this context (views.clj:181)",
unless I use declare. views.clj:181 is the last line of the
comments-rendition-recur defn.
What's going on, here?
Code also on http://paste.pocoo.org/show/463499/
---
(defhtml comment-rendition
[{:keys [index parent author link body created updated time-stamps
css-class]} children]
[:div.comment
time-stamps
[:div {:class (str "comment-body " css-class)}
[:p.meta
[:a.comment-anchor {:name index :href (str "#" index)}
(str "#" index " ")]
[:span.author [:a {:href link} author] ":"]]
body
children]])
(defhtml comment-new-level
[]
[:div {:class "hyphenate editable start-blank new-level"} "foo"])
(declare comments-rendition-recur)
(defn comments-rendition-recur
"Recurse for nested Comments."
[comments]
(cons
;; comments are [parent children] lists:
(map #(let [c (first %)
cs (rest %)]
(apply comment-rendition (if (empty? cs)
;; Create one level deeper, just for
;; the reply field:
[c (comment-new-level)]
;; Recurse to handle cs:
[(into c (derive-time-stamps c))
(comments-rendition-recur cs)])))
comments)
;; Place comment field like a last sibling:
(html [:div {:class "hyphenate editable start-blank end"}
(-> comments last first :parent)])))
(defhtml comments-rendition
[comments]
[:div#comments
[:h3 "Comments"]
[:noscript [:p "Without JavaScript, you cannot add comments, here!"]]
(comments-rendition-recur comments)])
(defhtml tree-rendition
[{:keys [comments] :as all}]
(article-rendition (into all
(derive-time-stamps all)))
(comments-rendition comments))
--
Thorsten Wilms
thorwil's design for free software:
http://thorwil.wordpress.com/
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en