wycats/handlebars.js — Issue #167: problematic scope with a custom block helper?
Author: nagyv
Created: 2012-01-26 01:06:47+00:00
State: open

hi,

I'm writing my first helper, but get stuck as handlebars complains about an "Uncaught TypeError"

I get the error

handlebars-utils.js:8Uncaught TypeError: Cannot call method 'get' of undefined

for the following helper, the logs are to show that everything exists as expected, statusapp is a global variable

Handlebars.registerHelper('characterById', function(cid, options) {
console.log(statusapp)
console.log(statusapp.collections)
console.log(statusapp.collections['characters'])
console.log(statusapp.collections['characters'].get)
console.log(statusapp.collections['characters'].get(cid))

var character = statusapp.collections['charaters'].get(cid);
return character.get(options.hash['attr']);
});

I call the above in my template with

{{#each friends}}

{{#characterById this attr="name"}}{{/characterById}}

{{/each}}

Could someone tell me how to fix this? Is there a bug in my code or something I've missed related to handlebar?

thanks, Viktor