I have a game and I want a system that renders a template if they have any adventures left.
Meteor.methods({
adventure: function () {
if(Meteor.user().adv > 0)
{
Meteor.users.update({_id: this.userId}, {$inc: {'adv': -1 }});
this.render('adv');
}
else
{
this.render('noadventures');
}
},
})
I have a template named adv but It wont load..
Use Blaze.render or Blaze.renderWithData - like so:
Meteor.methods({
adventure: function () {
if(Meteor.user().adv > 0)
{
Meteor.users.update({_id: this.userId}, {$inc: {'adv': -1 }});
Blaze.render(Template.adv, $('body').get(0);
}
else
{
Blaze.render(Template.noadventures, $('body').get(0);
}
},
})
You can do more with this - the documentation is pretty good.