{"action":"created","issue":{"url":"https://api.github.com/repos/meteor/meteor/issues/4035","labels_url":"https://api.github.com/repos/meteor/meteor/issues/4035/labels{/name}","comments_url":"https://api.github.com/repos/meteor/meteor/issues/4035/comments","events_url":"https://api.github.com/repos/meteor/meteor/issues/4035/events","html_url":"https://github.com/meteor/meteor/issues/4035","id":64606990,"number":4035,"title":"`Template.instance()` is `null` in nested helpers.","user":{"login":"xbtsw","id":4098537,"avatar_url":"https://avatars.githubusercontent.com/u/4098537?v=3","gravatar_id":"","url":"https://api.github.com/users/xbtsw","html_url":"https://github.com/xbtsw","followers_url":"https://api.github.com/users/xbtsw/followers","following_url":"https://api.github.com/users/xbtsw/following{/other_user}","gists_url":"https://api.github.com/users/xbtsw/gists{/gist_id}","starred_url":"https://api.github.com/users/xbtsw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xbtsw/subscriptions","organizations_url":"https://api.github.com/users/xbtsw/orgs","repos_url":"https://api.github.com/users/xbtsw/repos","events_url":"https://api.github.com/users/xbtsw/events{/privacy}","received_events_url":"https://api.github.com/users/xbtsw/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/meteor/meteor/labels/confirmed","name":"confirmed","color":"e10c02"},{"url":"https://api.github.com/repos/meteor/meteor/labels/Project:Blaze","name":"Project:Blaze","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-26T18:54:03Z","updated_at":"2015-04-10T16:39:15Z","closed_at":null,"body":"When the helper is a nested dictionary, `Template.instance()` inside the helper will return `null`\r\n\r\nTo reproduce:\r\n`meteor create app`\r\n\r\nchange `app.js` and `app.html` as follows:\r\n\r\n```js\r\n//app.js\r\n\r\n\r\nif (Meteor.isClient) {\r\n  // counter starts at 0\r\n  Session.setDefault('counter', 0);\r\n\r\n  Template.hello.helpers({\r\n    c: {\r\n      counter: function () {\r\n        //below line will throw exception since Template.instance() is null\r\n        var data = Template.instance().data;\r\n        return Session.get('counter');\r\n      }\r\n    }\r\n  });\r\n\r\n  Template.hello.events({\r\n    'click button': function () {\r\n      // increment the counter when button is clicked\r\n      Session.set('counter', Session.get('counter') + 1);\r\n    }\r\n  });\r\n}\r\n\r\nif (Meteor.isServer) {\r\n  Meteor.startup(function () {\r\n    // code to run on server at startup\r\n  });\r\n}\r\n```\r\n\r\n```html\r\n<!-- app.html -->\r\n\r\n<head>\r\n  <title>app</title>\r\n</head>\r\n\r\n<body>\r\n  <h1>Welcome to Meteor!</h1>\r\n\r\n  {{> hello}}\r\n</body>\r\n\r\n<template name=\"hello\">\r\n  <button>Click Me</button>\r\n  <p>You've pressed the button {{c.counter}} times.</p>\r\n</template>\r\n```\r\n\r\nIf we remove the extra level in helper dictionary:\r\ni.e. change `c.counter` to `counter` then `Template.instance()` will behave normally."},"comment":{"url":"https://api.github.com/repos/meteor/meteor/issues/comments/91611800","html_url":"https://github.com/meteor/meteor/issues/4035#issuecomment-91611800","issue_url":"https://api.github.com/repos/meteor/meteor/issues/4035","id":91611800,"user":{"login":"LyuGGang","id":5120987,"avatar_url":"https://avatars.githubusercontent.com/u/5120987?v=3","gravatar_id":"","url":"https://api.github.com/users/LyuGGang","html_url":"https://github.com/LyuGGang","followers_url":"https://api.github.com/users/LyuGGang/followers","following_url":"https://api.github.com/users/LyuGGang/following{/other_user}","gists_url":"https://api.github.com/users/LyuGGang/gists{/gist_id}","starred_url":"https://api.github.com/users/LyuGGang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LyuGGang/subscriptions","organizations_url":"https://api.github.com/users/LyuGGang/orgs","repos_url":"https://api.github.com/users/LyuGGang/repos","events_url":"https://api.github.com/users/LyuGGang/events{/privacy}","received_events_url":"https://api.github.com/users/LyuGGang/received_events","type":"User","site_admin":false},"created_at":"2015-04-10T16:39:15Z","updated_at":"2015-04-10T16:39:15Z","body":"+1"}}