Skip to content

Instantly share code, notes, and snippets.

@samselikoff
Last active January 31, 2017 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samselikoff/a9e9e376f9726c5aa8255c1c1a021ae8 to your computer and use it in GitHub Desktop.
Save samselikoff/a9e9e376f9726c5aa8255c1c1a021ae8 to your computer and use it in GitHub Desktop.
Customize component blocks
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
registerProfile(profile) {
this.set('profile', profile);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super(...arguments);
this.get('did-init')();
},
name: 'Josh Smith'
});
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super(...arguments);
this.get('on-init')(this);
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
button {
font-size: 18px;
margin: 20px;
}
.AttendeeCard {
display: flex;
border: 1px solid red;
}
.AttendeeCard-panel {
flex: 1;
text-align: center;
}
{{#attendee-card as |ac|}}
{{/attendee-card}}
{{#attendee-card as |ac|}}
{{#ac.profile}}
Sam Selikoff
{{/ac.profile}}
{{/attendee-card}}
{{yield (hash
profile=(component 'attendee-card/x-profile' did-init=(action 'registerProfile'))
)}}
<div class='AttendeeCard'>
<div class='AttendeeCard-panel'>
{{#unless profile}}
{{attendee-card/x-profile}}
{{/unless}}
</div>
<div class='AttendeeCard-panel'>
{{attendee-card/x-button}}
</div>
</div>
<h2>
I am
{{#if hasBlock}}
{{yield}}
{{else}}
Default
{{/if}}
</h2>
{
"version": "0.11.0",
"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.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment