Parameter not transmitted when using dot notation and parameterized helper


I would like to pass a parameter to helper and access the properties of the returned object by key in blaze.

My helper looks like:
teamById: function(teamId){ console.log('TEAM ID', teamId); return TeamsCollection.findOne({'_id': teamId}); }

What is working

{{teamById teamId}}

In first case the parameter is transmitted and I see the value in the console. In the second case I get the teams name.

What is not working is the combination:
{{ teamId}}

and in the console output it states undefined for the teamId value

Spacebars doesn’t support this type of syntax directly. You could wire something similar up using nested sub-expressions though:


  {{teamName (teamById 123)}}


  teamById(teamId) {
    return {
      _id: '123',
      name: 'Some Team'
  teamName() {

That being said, this approach isn’t that flexible. You’re probably better off just sticking with:

{{#with (teamById 123)}}

Thanks. I was not not familiar with the fact that you can not combine the blaze syntax in that way. I ended up with helper returning object or its value dependent on passed parameter.

teamById: function(teamId, param){
var team = TeamsCollection.findOne({'_id': teamId});
if (param && param in team){
  return team[param];
else {
  return team;