sproutcore/sproutcore20 — Issue #207: bindClass Handlebars Helpers
Author: ppcano
Created: 2011-11-16 12:22:39+00:00
State: open

I don't know if it could be a better way to do that, but i found writing unnecessary view code on my view content items.

The following [gist](https://gist.github.com/1369876), details the problem.

To sum up: When using bindAttr, i need to write something like that on my view items.

```javascript
TabItem = SC.Object.extend({
name: null,
selected: false,

nameClass: function(){
var result = 'name';
if ( get(this, 'selected') ) {
result+= ' selected';
}
return result;
}.property('selected').cacheable(),

imgClass: function(){
var result = 'img';
if ( get(this, 'selected') ) {
result+= ' selected';
}

return result;
}.property('selected').cacheable()

});
```

I think adding a **bindClass** helper like the one detailed on the [gist](https://gist.github.com/1369876) could be useful, perhaps there is a better way to achieve the same goal.