{"action":"created","issue":{"url":"https://api.github.com/repos/meteor/meteor/issues/5087","labels_url":"https://api.github.com/repos/meteor/meteor/issues/5087/labels{/name}","comments_url":"https://api.github.com/repos/meteor/meteor/issues/5087/comments","events_url":"https://api.github.com/repos/meteor/meteor/issues/5087/events","html_url":"https://github.com/meteor/meteor/issues/5087","id":104251325,"number":5087,"title":"Blaze: how to dereference a helper with an argument?","user":{"login":"AlexFrazer","id":1350392,"avatar_url":"https://avatars.githubusercontent.com/u/1350392?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexFrazer","html_url":"https://github.com/AlexFrazer","followers_url":"https://api.github.com/users/AlexFrazer/followers","following_url":"https://api.github.com/users/AlexFrazer/following{/other_user}","gists_url":"https://api.github.com/users/AlexFrazer/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexFrazer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexFrazer/subscriptions","organizations_url":"https://api.github.com/users/AlexFrazer/orgs","repos_url":"https://api.github.com/users/AlexFrazer/repos","events_url":"https://api.github.com/users/AlexFrazer/events{/privacy}","received_events_url":"https://api.github.com/users/AlexFrazer/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-01T12:12:45Z","updated_at":"2015-09-01T21:01:20Z","closed_at":"2015-09-01T21:01:20Z","body":"Example helper:\r\n\r\n```\r\nTemplate['Admin.console'].helpers({\r\n  socket: function (name) {\r\n    return Connections.findOne({ name: name }, {\r\n      sort: { timestamp: 1 }\r\n    });\r\n  }\r\n});\r\n\r\nTemplate.registerHelper('hasResults', (cursor) => {\r\n  if (cursor instanceof Mongo.Cursor) return cursor.count() > 0;\r\n  else if (cursor instanceof Array) return cursor.length;\r\n  return !!cursor;\r\n});\r\n```\r\n\r\nThen in a template:\r\n\r\n```\r\nif hasResults(socket 'commands')\r\n  each (socket 'commands').messages\r\n    div\r\n      | {{ message }}\r\n```\r\n\r\nIs this possible? If not, can support be added?"},"comment":{"url":"https://api.github.com/repos/meteor/meteor/issues/comments/136860390","html_url":"https://github.com/meteor/meteor/issues/5087#issuecomment-136860390","issue_url":"https://api.github.com/repos/meteor/meteor/issues/5087","id":136860390,"user":{"login":"dgreensp","id":155814,"avatar_url":"https://avatars.githubusercontent.com/u/155814?v=3","gravatar_id":"","url":"https://api.github.com/users/dgreensp","html_url":"https://github.com/dgreensp","followers_url":"https://api.github.com/users/dgreensp/followers","following_url":"https://api.github.com/users/dgreensp/following{/other_user}","gists_url":"https://api.github.com/users/dgreensp/gists{/gist_id}","starred_url":"https://api.github.com/users/dgreensp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgreensp/subscriptions","organizations_url":"https://api.github.com/users/dgreensp/orgs","repos_url":"https://api.github.com/users/dgreensp/repos","events_url":"https://api.github.com/users/dgreensp/events{/privacy}","received_events_url":"https://api.github.com/users/dgreensp/received_events","type":"User","site_admin":false},"created_at":"2015-09-01T21:01:20Z","updated_at":"2015-09-01T21:01:20Z","body":"Jade templating is a community package, so I can't answer for sure if this is possible or not, but if you are using `mquandalle:jade`, I think it uses the same expression syntax as Meteor's Spacebars templating.\r\n\r\nWe've talked about adding fancier expression support to Spacebars, but it is not on our immediate roadmap.\r\n\r\nThe usual way to write this template code (in Spacebars at least) would be to assign the socket to a variable or the data context, using `#let` or `#with`, and then refer to it.  This also means the database query is only done once rather than twice."}}