Skip to content

Instantly share code, notes, and snippets.

@jelhan
Created July 22, 2016 15:59
Show Gist options
  • Save jelhan/2823cd9aaa0ecf80ae6ff1350020eecb to your computer and use it in GitHub Desktop.
Save jelhan/2823cd9aaa0ecf80ae6ff1350020eecb to your computer and use it in GitHub Desktop.
ember-bootstrap/116
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this.set('useIconsIsDefault',
!this.attrs.hasOwnProperty('useIcons')
);
this._super(...arguments);
},
useIcons: true
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>no block, no override</h1>
{{my-component}}
<h1>no block, but override</h1>
{{my-component useIcons=false}}
<h1>block without override</h1>
{{#my-component}}{{/my-component}}
<h1>block with override</h1>
{{#my-component useIcons=true}}{{/my-component}}
{{#if hasBlock}}
{{#if useIconsIsDefault}}
<p>Do not show icons.</p>
{{else}}
<p>{{useIcons}}</p>
{{/if}}
{{else}}
<p>{{useIcons}}</p>
{{/if}}
{
"version": "0.10.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.6.0",
"ember-data": "2.6.1",
"ember-template-compiler": "2.6.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment