Module: Proclaim::ApplicationHelper

Defined in:
app/helpers/proclaim/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#comments_tree_for(comments) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/proclaim/application_helper.rb', line 3

def comments_tree_for(comments)
	comments.map do |comment, nested_comments|
		commentHtml = render(partial: "proclaim/comments/comment",
		                     formats: [:html],
		                     locals: {
		                     	comment: comment,
		                     	target: "#comment_#{comment.id}_replies"
		                     })

		nestedComments = ""
		if nested_comments.size > 0
			nestedComments = comments_tree_for(nested_comments)
		end

		repliesHtml = (:div, nestedComments,
		                          id: "comment_#{comment.id}_replies",
		                          class: "replies")

		(:div, commentHtml + repliesHtml, class: "discussion")
	end.join.html_safe
end