mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
simplifying templates
This commit is contained in:
parent
507540af1d
commit
deb84431d2
6 changed files with 36 additions and 25 deletions
|
@ -13,5 +13,12 @@
|
|||
<div class="comment-text">{{body}}</div>
|
||||
<a href="#" class="comment-reply">Reply</a>
|
||||
</div>
|
||||
<ul class="comment-children">
|
||||
{{#each comments}}
|
||||
{{#with this}}
|
||||
{{> comment}}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
</li>
|
||||
</template>
|
||||
|
|
|
@ -10,3 +10,9 @@ Template.comment.ago = function(){
|
|||
var submitted = new Date(this.submitted);
|
||||
return submitted.toString();
|
||||
};
|
||||
|
||||
Template.comment.comments = function(){
|
||||
var post = Session.get('selected_post');
|
||||
var comments = Comments.find({ post: post._id, parent: this._id });
|
||||
return comments;
|
||||
};
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<template name="comments">
|
||||
{{#if show}}
|
||||
<ul>
|
||||
{{#each comments}}
|
||||
{{> comment}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
{{else}}
|
||||
<p>No comments.</p>
|
||||
{{/if}}
|
||||
</template>
|
|
@ -1,11 +0,0 @@
|
|||
Template.comments.show = function(){
|
||||
var post = Session.get('selected_post');
|
||||
var comments = Comments.find({ post: post._id });
|
||||
return comments.count() > 0;
|
||||
};
|
||||
|
||||
Template.comments.comments = function(){
|
||||
var post = Session.get('selected_post');
|
||||
var comments = Comments.find({ post: post._id });
|
||||
return comments;
|
||||
};
|
|
@ -1,11 +1,12 @@
|
|||
<template name="selected_post">
|
||||
{{#if show}}
|
||||
{{#with post}}
|
||||
<div class="selected-post grid">
|
||||
{{#with post}}
|
||||
{{> post}}
|
||||
{{#if body}}
|
||||
<div class="post-message">{{body}}</div>
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
<div class="comment-new">
|
||||
<div class="comment-field">
|
||||
<textarea id="comment" rows="3" autofocus="autofocus"></textarea>
|
||||
|
@ -14,8 +15,15 @@
|
|||
<input type="submit" value="Add Comment" />
|
||||
</div>
|
||||
</div>
|
||||
{{> comments}}
|
||||
{{#if has_comments}}
|
||||
<ul>
|
||||
{{#each comments}}
|
||||
{{> comment}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
{{else}}
|
||||
<p>No comments.</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
</template>
|
||||
|
|
|
@ -21,3 +21,15 @@ Template.selected_post.post = function(){
|
|||
var post = Session.get('selected_post');
|
||||
return post;
|
||||
};
|
||||
|
||||
Template.selected_post.has_comments = function(){
|
||||
var post = Session.get('selected_post');
|
||||
var comments = Comments.find({ post: post._id, parent: null });
|
||||
return comments.count() > 0;
|
||||
};
|
||||
|
||||
Template.selected_post.comments = function(){
|
||||
var post = Session.get('selected_post');
|
||||
var comments = Comments.find({ post: post._id, parent: null });
|
||||
return comments;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue