Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save code0100fun/f5922b6f44eee2abc21d to your computer and use it in GitHub Desktop.
Save code0100fun/f5922b6f44eee2abc21d to your computer and use it in GitHub Desktop.
Ember component with optional block
<!-- app/templates/*.hbs -->
{{#if template}}
{{yield}}
{{else}}
{{defaultContent}}
{{/if}}
//tests/unit/components/*.js
test('component with optional block', function(assert) {
assert.expect(1);
var component = this.subject();
Ember.run(function(){
component.set('template', function(){ return 'Something else'; });
component.set('defaultContent', 'foo');
});
assert.trimEq(this.$().text(), 'Something else');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment