I have the following code:
Template.leaderboard.players = function() {
return Players.find({}, {sort: {score: -1, name: 1}});
};
Template.leaderboard.selected_name = function() {
var player = Players.findOne(Session.get("selected_player"));
return player && player.name;
};
And I would like to organize it more clearly like that:
Template.leaderboard = {
players: function() {
return Players.find({}, {sort: {score: -1, name: 1}});
},
selected_name: function() {
var player = Players.findOne(Session.get("selected_player"));
return player && player.name;
}
};
The problem is (I believe from the errors in the console) that this overwrites all the existing methods of the Template.leaderboard
object and replaces it.
Is there a possibility to add those methods to the object while keeping existing methods using the kind of notation shown above?