Skip to content

Instantly share code, notes, and snippets.

@mariechatfield
Created March 30, 2018 18:35
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 mariechatfield/e494bdd15cb68a1b8591a333b7ccb793 to your computer and use it in GitHub Desktop.
Save mariechatfield/e494bdd15cb68a1b8591a333b7ccb793 to your computer and use it in GitHub Desktop.
Yield Multiple Blocks
import Ember from 'ember';
export default Ember.Component.extend({
});
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;
}
.wrapper {
margin: 10px;
}
.block {
padding: 20px;
border: 1px solid black;
}
.print--active {
background-color: #efef;
}
{{#my-component as |block|}}
{{#if block.isPrintActive}}
I only render if print is active!
{{else}}
I only render if print is inactive!
{{/if}}
{{/my-component}}
{{#my-component as |block|}}
{{#if block.isPrintActive}}
Do your default for non-print, I don't care.
{{/if}}
{{/my-component}}
{{#my-component as |block|}}
{{#unless block.isPrintActive}}
Do your default for print, I don't care.
{{/unless}}
{{/my-component}}
<div class="wrapper">
<div class="block print--active">
{{yield (hash isPrintActive=true)}}
</div>
<div class="block print--inactive">
{{yield (hash isPrintActive=false)}}
</div>
</div>
{
"version": "0.13.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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment