Skip to content

Instantly share code, notes, and snippets.

@max
Last active January 18, 2016 23:30
Show Gist options
  • Save max/6467132a7d30f4fdab59 to your computer and use it in GitHub Desktop.
Save max/6467132a7d30f4fdab59 to your computer and use it in GitHub Desktop.
Contextual Components
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
{{some-component button=(component 'my-button' label='My Label')}}
<p class="u-quiet"><small>I'm already passing in a component with <code>(component 'my-button')</code>. Why can't I just use <code>{{button}}</code> to invoke it.</small></p>
<button class="My-Button">{{label}}</button>
<p>This is an awesome component from somewhere. And I can pass in a custom button.</p>
{{component button}}
body {
color: #444;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 1.5;
padding: 1rem;
}
.u-quiet {
color: #999;
}
.My-Button {
background: #0069FF;
border: none;
border-radius: 4px;
color: white;
font-size: inherit;
padding: 0.5rem 2rem;
}
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "release",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "release"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment