Skip to content

Instantly share code, notes, and snippets.

@dbachet
Forked from ppcano/controllers.application.js
Last active April 9, 2020 16:50
Show Gist options
  • Save dbachet/88e78ba5ea747a5ddcef36e8033c8a46 to your computer and use it in GitHub Desktop.
Save dbachet/88e78ba5ea747a5ddcef36e8033c8a46 to your computer and use it in GitHub Desktop.
New Twiddle
import Component from '@ember/component';
export default Component.extend({
tagName: 'div',
classNames: ['yay-class']
});
import Ember from 'ember';
import {computed} from '@ember/object';
export default Ember.Controller.extend({
appName: 'Ember - Workaround to yield multiple blocks',
step: 1,
someComponentPath: computed('step', function(){
return this.step == 1 ? 'my-footer' : 'my-component-name';
}),
actions: {
toggleTemplate(){
if (this.step == 1) {
this.set('step', 2);
} else {
this.set('step', 1);
}
}
}
});
{{my-component content=someComponentPath}}
<button type="button" {{action "toggleTemplate"}}>change template</button>
<div style="color:red;">
YAY
</div>
<div class="container">
{{component content}}
</div>
{{#if hasBlock}}
{{yield}}
{{else}}
Default header
{{/if}}
import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { assign } from '@ember/polyfills';
import { start } from 'ember-qunit';
let attributes = {
rootElement: '#test-root',
autoboot: false
};
attributes = assign(attributes, config.APP);
let application = Application.create(attributes);
setApplication(application);
start();
{
"version": "0.15.0",
"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.2.2",
"ember-template-compiler": "3.2.2",
"ember-testing": "3.2.2"
},
"addons": {
"ember-data": "3.2.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment