Skip to content

Instantly share code, notes, and snippets.

@GavinJoyce
Created March 22, 2017 16:54
Show Gist options
  • Select an option

  • Save GavinJoyce/208bc2b4738d806c35345fdd0579367f to your computer and use it in GitHub Desktop.

Select an option

Save GavinJoyce/208bc2b4738d806c35345fdd0579367f to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Em from 'ember';
export default Em.Controller.extend({
name: 'alex',
badTitle: Em.computed('name', function() {
let name = this.get('name');
return Em.String.htmlSafe(`hi <b>${name}</b>!!`);
})
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.title {
background-color: yellow;
padding: 10px;
}
.body {
background-color: lightgreen;
padding: 10px;
min-height: 100px;
}
<h2>Card Component:</h2>
name: {{input value=name}}
<hr />
{{#card-component title="This can't have HTML"}}
<h3>content</h3>
{{/card-component}}
<hr />
{{#card-component title=badTitle}}
<h3>content</h3>
{{/card-component}}
<hr />
{{#super-card-component as |card|}}
{{#card.title}}
hi <b>{{name}}</b>!
{{/card.title}}
{{#card.body}}
<h3>content here</h3>
{{/card.body}}
{{/super-card-component}}
<hr />
{{#super-card-component title="this is the title" as |card|}}
{{#card.body}}
<h3>just the body</h3>
{{/card.body}}
{{/super-card-component}}
<div class="title">
{{title}}
</div>
<div class="body">
{{yield}}
</div>
{{#if title}}
{{super-card-title-component title=title}}
{{else}}
{{yield
(hash
title=(component 'super-card-title-component')
)
}}
{{/if}}
{{yield
(hash
body=(component 'super-card-body-component')
)
}}
<div class="title">
{{#if hasBlock}}
{{yield}}
{{else}}
{{title}}
{{/if}}
</div>
{
"version": "0.12.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.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