Skip to content

Instantly share code, notes, and snippets.

@arm1n
Last active February 11, 2019 14:33
Show Gist options
  • Save arm1n/e5ac349647077f3b0de36749f8280fdf to your computer and use it in GitHub Desktop.
Save arm1n/e5ac349647077f3b0de36749f8280fdf to your computer and use it in GitHub Desktop.
c-box
import Ember from 'ember';
export default Ember.Component.extend({
classNames:['c-box-body']
});
import Ember from 'ember';
export default Ember.Component.extend({
classNames:['c-box-head']
});
import Component from '@ember/component';
export default Component.extend({
classNames:['c-box']
});
import Ember from 'ember';
export default Ember.Controller.extend({});
<h1>c-box</h1>
{{#c-box as |b|}}
{{#b.body}}
Content
{{/b.body}}
{{/c-box}}
<hr/>
{{#c-box title='Plain title' as |b|}}
{{#b.body}}
Content
{{/b.body}}
{{/c-box}}
<hr/>
{{#c-box as |b|}}
{{#b.head}}
Custom title
{{/b.head}}
{{#b.body}}
Content
{{/b.body}}
{{/c-box}}
{{#let (hash
head=(component 'c-box-head')
body=(component 'c-box-body')
) as |data|}}
{{!-- render title implicity if `title` property --}}
{{#if title}}
{{#data.head}}
{{title}}
{{/data.head}}
{{/if}}
{{!-- yield all data to consuming template --}}
{{yield data}}
{{/let}}
{
"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