Skip to content

Instantly share code, notes, and snippets.

@elwayman02
Created July 14, 2015 20:10
Show Gist options
  • Save elwayman02/1ac2cabeb1dd722a2ffa to your computer and use it in GitHub Desktop.
Save elwayman02/1ac2cabeb1dd722a2ffa to your computer and use it in GitHub Desktop.
Class definition separation
// foo-component.js
export default Ember.Component.extend({
classNames: ['foo'],
barClasses: Ember.computed('bar', function () {
return this.get('bar') ? 'foo bar' : 'foo';
}),
bazClasses: Ember.computed('baz', function () {
return this.get('baz') ? 'baz' : '';
})
});
// foo.component.hbs
<div class='foo-header'>
<span class=barClasses>I am bar</span>
<div class='stuff things'>{{things-list things}}</div>
<div class=bazClasses>
{{#each bazItems as |item|}}
{{baz-component item}}
{{/each}}
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment