Skip to content

Instantly share code, notes, and snippets.

@olivia
Last active November 3, 2015 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save olivia/5b03d8235ab3652019de to your computer and use it in GitHub Desktop.
Save olivia/5b03d8235ab3652019de to your computer and use it in GitHub Desktop.
Yield example
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
<h2>Standard Form</h2>
{{x-parent}}
<h2>Yield Form</h2>
{{#x-parent obj as |prop1 do1 do2|}}
<ul>
<li><a href {{action do1}}>Log 1</a></li>
<li><a href {{action do2}}>Log 2</a></li>
<li>Bound prop: {{prop1}}</li>
</ul>
{{/x-parent}}
{{outlet}}
<br>
<br>
{
"version": "0.4.16",
"EmberENV": {
"FEATURES": {}
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.1.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember-template-compiler.js"
}
}
import Ember from 'ember';
export default Ember.Component.extend({
prop1: 'foo',
actions: {
do1: function(){
console.log('1');
},
do2: function(){
console.log('2');
}
}
});
{{#if hasBlockParams}}
{{yield prop1 (action 'do1') (action 'do2')}}
{{else}}
<ul>
<li><a href {{action 'do1'}}>Log 1</a></li>
<li><a href {{action 'do2'}}>Log 2</a></li>
<li>Bound prop: {{prop1}}</li>
</ul>
{{/if}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment