Created
December 14, 2016 19:59
-
-
Save goors/04f3e9597d6d155a7dfa2d97630fa52b to your computer and use it in GitHub Desktop.
Google/Facebook like comments recursion with node.js jade template enging using mixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if post.comments != undefined && post.comments.length | |
.container | |
.row | |
.comments-container | |
h2="Comments" | |
ul#comments-list.comments-list | |
mixin commentView(comment) | |
- var children = post.comments.filter(function(child) { return comment.id === parseInt(child.parent); }) | |
- console.log(children) | |
if comment.parent != "" | |
li | |
.comment-avatar | |
if comment.user.avatar == "" | |
img(src='https://ssl.gstatic.com/accounts/ui/avatar_2x.png', alt='') | |
else | |
img(src='accounts/' + comment.user.id + "/" + comment.user.avatar, alt='') | |
.comment-box | |
.comment-head | |
h6.comment-name(class=(comment.user.id == post.idOwner ? 'by-author' : '')) | |
a()=comment.user.first_name + " " + comment.user.last_name | |
span hace 10 minutos | |
i.fa.fa-reply(data-ng-click="addComment('" + post.slug + "', '" + comment.id + "')") | |
.comment-content=comment.comment | |
each comment in children | |
ul.comments-list.reply-list | |
+commentView(comment) | |
li | |
each comment in post.comments | |
if comment.parent == "" | |
.comment-main-level | |
.comment-avatar | |
if comment.user.avatar == "" | |
img(src='https://ssl.gstatic.com/accounts/ui/avatar_2x.png', alt='') | |
else | |
img(src='accounts/' + comment.user.id + "/" + comment.user.avatar, alt='') | |
.comment-box | |
.comment-head | |
h6.comment-name(class=(comment.user.id == post.idOwner ? 'by-author' : '')) | |
a()=comment.user.first_name + " " + comment.user.last_name | |
span=moment.unix(comment.createdAt).format("DD-MMM-YYYY, h:mm:ss a") | |
i.fa.fa-reply(data-ng-click="addComment('" + post.slug + "', '" + comment.id + "')") | |
.comment-content=comment.comment | |
+commentView(comment) | |
.clear | |
.clear | |
.clear | |
.clear | |
.clear |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Html and css at: http://bootsnipp.com/snippets/459K9