I am having issues with either Flow Router or my template level subscriptions but the data is not being rendered on the page.
Just incase the issue isn't what I have pasted here I have included a link to the entire github repo: https://github.com/adjohnston/checkr-meteor
lib/routes.js
listRoutes.route('/:slug', {
name: 'list',
subscriptions: function (params) {
this.register('singleList', Meteor.subscribe('singleList', params.slug));
},
action: function () {
FlowLayout.render('mainLayout', {
main: 'list'
});
}
});
server/publication/lists.js
Meteor.publish('singleList', function (slug) {
return Lists.find({slug: slug});
});
client/lists/list.js
Template.list.helpers({
singleList: function () {
return Lists.find();
}
});
client/lists/list.html
<template name="list">
{{#if isSubReady}}
{{#with singleList}}
<h2>Name: {{name}}</h2>
{{/with}}
{{/if}}
</template>
Solution
Change returns Lists.find() to Lists.findOne() since the publication 'singleList' is only returning a single result.
client/lists/list.js
Template.list.helpers({
singleList: function () {
return Lists.findOne();
}
});
Try changing your
singleList
helper to afindOne
:Right now you are trying to display the
name
property of a cursor, which is whatfind()
returns. You also don't need{{#with singleList}}
in your handlebars.