We were using a <ul> tag for a single comment, where the first element of the list was the comment itself and the second element was the list of replies. IMHO it makes more sense to have a list of all comments, where every element is a comment and inside it there's a list of replies. We're also rendering the list even if it has no children so it's easier to add comments through JavaScript. Then we use the :empty CSS selector to hide the list if it's empty. However, since ERB adds whitespace if we structure our code the usual way and current browsers don't recognize elements with whitespace as empty, we have to use the `tag` helper so no whitespace is added.
8 lines
253 B
Plaintext
8 lines
253 B
Plaintext
<% valuation = local_assigns.fetch(:valuation, false) %>
|
|
|
|
<%= tag.ul class: "no-bullet comment-list" do %>
|
|
<% comments.each do |comment| %>
|
|
<%= tag.li render("comments/comment", { comment: comment, valuation: valuation }) %>
|
|
<% end %>
|
|
<% end %>
|