Is there a good way to render the result of a promise in a handlebars template?
For example, I have the following model:
App.TopicItem = DS.Model.extend({
topic: DS.belongsTo('topic'),
paddedPosition: function() {
return this.get('topic.course.lessons').
then(function(lessons) {
return lessons.indexOf(topicItem);
}).
then(function(index){
var position = index;
if (position < 0) {
return;
}
position = position + 1;
return (position < 10 ? $.rjust(position, 2, '0') : position.toString());
});
}.property('topic.course.lessons')
});
And I would like to render the value of the position in the handlebars template like this:
{{topicItem.paddedPosition}}
Is there a good way to accomplish this?