making post route non-reactive

This commit is contained in:
Sacha Greif 2013-10-21 17:47:30 +08:00
parent 68a83868d8
commit e76e7b06bc
6 changed files with 18 additions and 11 deletions

View file

@ -335,8 +335,10 @@ Router.map(function() {
// }
// },
data: function() {
// note: do not pass actual post object in data property because we don't want the route to be reactive
// and re-run every time a post score changes
return {
post: Posts.findOne(this.params._id)
postId: this.params._id
}
}
});

View file

@ -4,7 +4,7 @@ Template.comment_list.created = function(){
Template.comment_list.helpers({
has_comments: function(){
console.log(this)
// console.log(this)
// note: use this.post to access 'post' object in router data context
if(this.post)
return Comments.find({post: postObject._id, parent: null}, {sort: {score: -1, submitted: -1}}).count() > 0;

View file

@ -1,11 +1,13 @@
<template name="post_page">
{{#if canView}}
<div class="single-post grid">
{{> post_item}}
{{#if canComment}}
{{> comment_form}}
{{/if}}
{{> comment_list}}
</div>
{{#with post}}
<div class="single-post grid">
{{> post_item}}
{{#if canComment}}
{{> comment_form}}
{{/if}}
{{> comment_list}}
</div>
{{/with}}
{{/if}}
</template>

View file

@ -1,4 +1,7 @@
Template.post_page.helpers({
post: function () {
return Posts.findOne(this.postId);
},
body_formatted: function(){
var converter = new Markdown.Converter();
var html_body=converter.makeHtml(this.body);

View file

@ -1 +1 @@
/Users/sacha/.meteorite/packages/iron-router/EventedMind/iron-router/13d0007ee9dfa1a111a0e55eedcf002c593f5489
/Users/sacha/.meteorite/packages/iron-router/EventedMind/iron-router/dddf61e618285ec2045a16f224870b1aeba05cdd

View file

@ -38,7 +38,7 @@
"iron-router": {
"git": "https://github.com/EventedMind/iron-router.git",
"branch": "dev",
"commit": "13d0007ee9dfa1a111a0e55eedcf002c593f5489"
"commit": "dddf61e618285ec2045a16f224870b1aeba05cdd"
},
"crypto-base": {
"git": "https://github.com/tmeasday/meteor-crypto-base.git",