inorder to make bindings work, you are required to use Ember.Handlebars.registerBoundHelper
Ember.Handlebars.registerBoundHelper('displayAttribute', function(value,options) {
if (typeof(tag) === 'undefined') {
tag = 'div';
}
// TODO: generate output string
return new Handlebars.SafeString(output);
}, dependentKeys);
Note that it takes 3 params.
@param {String} name
@param {Function} function
@param {String} dependentKeys*
For more documentation, i suggest to go through following links.
Ember API Docs
Ember Source Code
Here is the content from code docs
Example with options
Like normal handlebars helpers, bound helpers have access to the options passed into the helper call.
Ember.Handlebars.registerBoundHelper('repeat', function(value, options) {
var count = options.hash.count;
var a = [];
while(a.length < count) {
a.push(value);
}
return a.join('');
});
This helper could be used in a template as follows:
{{repeat text count=3}}
## Example with bound options
Bound hash options are also supported. Example:
{{repeat text countBinding="numRepeats"}}
In this example, count will be bound to the value of
the numRepeats
property on the context. If that property
changes, the helper will be re-rendered.
## Example with extra dependencies
The Ember.Handlebars.registerBoundHelper
method takes a variable length
third parameter which indicates extra dependencies on the passed in value.
This allows the handlebars helper to update when these dependencies change.
Ember.Handlebars.registerBoundHelper('capitalizeName', function(value) {
return value.get('name').toUpperCase();
}, 'name');
## Example with multiple bound properties
Ember.Handlebars.registerBoundHelper
supports binding to
multiple properties, e.g.:
Ember.Handlebars.registerBoundHelper('concatenate', function() {
var values = Array.prototype.slice.call(arguments, 0, -1);
return values.join('||');
});
Which allows for template syntax such as {{concatenate prop1 prop2}}
or
{{concatenate prop1 prop2 prop3}}
. If any of the properties change,
the helpr will re-render. Note that dependency keys cannot be
using in conjunction with multi-property helpers, since it is ambiguous
which property the dependent keys would belong to.
Here is the working jsbin as an example