<%! import django_comment_client.helpers as helpers %>

<%def name="render_content(content, *args, **kwargs)">
  ${helpers.render_content(content, *args, **kwargs)}
</%def>

<%def name="render_content_with_comments(content, *args, **kwargs)">
  <div class="${content['type'] | h}${helpers.show_if(' endorsed', content.get('endorsed')) | h}" _id="${content['id'] | h}" _discussion_id="${content.get('commentable_id', '') | h}" _author_id="${helpers.show_if(content['user_id'], not content.get('anonymous')) | h}">
    ${render_content(content, *args, **kwargs)}
    ${render_comments(content.get('children', []), *args, **kwargs)}
  </div>
</%def>

<%def name="render_comments(comments, *args, **kwargs)">
  <div class="comments">
    % for comment in comments:
      ${render_content_with_comments(comment, *args, **kwargs)}
    % endfor
  </div>
</%def>
