javascript - Ember.js Handlebars BoundHelper Uncaught TypeError: Object #<Object> has no method 'split' -


i'm making handlebars helper simplify translation ember app. needs able bind count option, because count change on time, , translation needs plural or singular based on count.

for example:

{{i18n translation.key countbinding='numbercount'}} 

will go language file , see

translation: {   key: {     'one': 'widget',     'other': 'widgets'   } } 

and return 'widget' or 'widgets' depending on value of numbercount

here code helper:

ember.handlebars.registerboundhelper('i18n', function(property, options) {   var params = options.hash,     self = this;    // support variable interpolation options   object.keys(params).foreach(function(key) {     params[key] = em.handlebars.get(self, params[key], options);   });    // coerce number-like strings numbers   if (params.count && !isnan(params.count) && typeof(params.count) == "string") {     params.count = number(params.count);   }    // i18n library powers translation   return i18n.t(property, params); }); 

if use ember.handlebars.registerhelper instead of registerboundhelper, works fine, won't bind option. when try make bound helper (as in code above), app not load , console gives me error "uncaught typeerror: object # has no method 'split' "

here docs ember.handlebars.registerboundhelper: http://emberjs.com/api/classes/ember.handlebars.html#method_registerboundhelper

would work if replace

var params = options.hash 

with

var params = options.hash.boundoptions 

and

{{i18n translation.key countbinding='numbercount'}} 

with

{{i18n translation.key count=numbercount}} 

? works in test environment.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -