Skip to content

Instantly share code, notes, and snippets.

@sukima
Last active May 26, 2020 22:44
Show Gist options
  • Save sukima/8c266f53719259ed8061b6eab92d00df to your computer and use it in GitHub Desktop.
Save sukima/8c266f53719259ed8061b6eab92d00df to your computer and use it in GitHub Desktop.
Multi-Yielding Component
.foo-wrapper {
background-color: #0000bb;
color: white;
padding: 10px;
}
.foo-wrapper__foo-a {
background-color: red;
color: white;
margin: 10px;
padding: 10px;
}
.foo-wrapper__foo-b {
background-color: yellow;
color: black;
margin: 10px;
padding: 10px;
}
.foo-wrapper__foo-c {
background-color: green;
color: white;
margin: 10px;
padding: 10px;
}
img {
max-width: 100%;
}
<div class="hack container">
<h1>Example</h1>
{{#foo-wrapper as |foo|}}
{{#foo.a}}This is the Foo A component{{/foo.a}}
{{#foo.b}}This is the Foo B component{{/foo.b}}
{{#foo.c}}This is the Foo C component{{/foo.c}}
{{/foo-wrapper}}
<h1>Output</h1>
<a href="https://imgur.com/9RdS8pH"><img src="https://i.imgur.com/9RdS8pH.png" title="source: imgur.com" /></a>
</div>
<div class="foo-wrapper">
<div class="foo-wrapper__foo-a">
{{yield (hash a=(component "foo-content"))}}
</div>
<div class="foo-wrapper__foo-b">
{{yield (hash b=(component "foo-content"))}}
</div>
<div class="foo-wrapper__foo-c">
{{yield (hash c=(component "foo-content"))}}
</div>
</div>
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"hack_css": "https://cdnjs.cloudflare.com/ajax/libs/hack/0.8.0/hack.css",
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment