Skip to content

Instantly share code, notes, and snippets.

@arackaf
Last active January 11, 2019 18:23
Show Gist options
  • Select an option

  • Save arackaf/8d3a8543fa451ef66f78b0ecb259867d to your computer and use it in GitHub Desktop.

Select an option

Save arackaf/8d3a8543fa451ef66f78b0ecb259867d to your computer and use it in GitHub Desktop.
rackis-ember-sandbox
import Ember from 'ember';
export default Ember.Component.extend({
});
<h1>Hello</h1>
a here --->
{{yield (hash ca=(component "comp-a") aVal="Hello aVal") }}
b here ===>
{{yield (hash cb=(component "comp-b") bVal="World bVal") }}
<h1>World</h1>
import Ember from 'ember';
export default Ember.Component.extend({
});
<h1>Comp A</h1>
{{yield}}
import Ember from 'ember';
export default Ember.Component.extend({
});
<h1>Comp B</h1>
{{yield}}
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
//So <h2>Middle</h2> is rendered *twice*, it seems. As near as I can tell, inside of blog-post,
// `{{yield (hash ca=(component "comp-a")) }}`
//means "render all of my children, and set **my own** prop of `ca` to the component
//comp-a. When that happens, `cb` is undefined, which is why the comp-b component doesn't render, there. And the reverse for the other line that sets cb to comp-b
//Coming from a react background it seems crazy that a component can set its own publicly accessible props, so I want to make sure I have that right
{{#blog-post x="Hi" as |post|}}
<h2>Middle</h2>
{{post.aVal}}
{{#post.ca}}
ca child
{{/post.ca}}
{{post.bVal}}
{{#post.cb}}
cb child
{{/post.cb}}
{{/blog-post}}
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment