Skip to content

Instantly share code, notes, and snippets.

@jjff
Created May 30, 2020 17:15
Show Gist options
  • Save jjff/e4fc12c3674c3097acc661d9261136b1 to your computer and use it in GitHub Desktop.
Save jjff/e4fc12c3674c3097acc661d9261136b1 to your computer and use it in GitHub Desktop.
New Twiddle
import Controller from '@ember/controller';
import { map } from '@ember/object/computed';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle'
chores = ['clean', 'write more unit tests']
@map('chores', function(e, i) {
return `${e.toUpperCase()}_${i+1}!`;
})
excitingChores;
}
/*
import { set } from '@ember/object';
import { map } from '@ember/object/computed';
class Hamster {
constructor(chores) {
set(this, 'chores', chores);
}
@map('chores', function(chore, index) {
return `${chore.toUpperCase()}!`;
})
excitingChores;
});
let hamster = new Hamster(['clean', 'write more unit tests']);
hamster.excitingChores; // ['CLEAN!', 'WRITE MORE UNIT TESTS!']
*/
<h1>Welcome to {{this.appName}}</h1>
<br />
<br />
Chores: <br />
{{#each chores as |i|}}
{{i}} <br />
{{/each}} <br />
ExcitingChores: <br />
{{#each excitingChores as |i|}}
{{i}}<br />
{{/each}}
{{outlet}}
<br />
<br />
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.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": false
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment