def load_comments(obj_response, post_id, depth):
comments = Post.query.filter_by(parent_id=post_id).order_by(Post.date)
if comments:
render_comment = get_template_attribute('macros.html', 'render_comment')
# clear the comments displayed (to avoid double loading of inserted comments)
obj_response.html(''.join(['#post-', str(post_id), '-comments']), '')
for comment in comments:
obj_response.html_append(''.join(['#post-', str(post_id), '-comments']),
render_comment(comment, current_user, depth).unescape())
# change the button to hide the comments if pressed again
obj_response.script(''.join(['$("#load_comment_button_', str(post_id), '").attr("onclick", "hide_comments(',
str(post_id), ',', str(depth), ')")']))
评论列表
文章目录