Skip to content

Instantly share code, notes, and snippets.

@machty
Last active October 19, 2017 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save machty/78b5fc11980f1cd793393cef10949f0f to your computer and use it in GitHub Desktop.
Save machty/78b5fc11980f1cd793393cef10949f0f to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
tagName: '',
depth: null,
depthMinusOne: Ember.computed(function() {
return this.get('depth') - 1;
}),
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export function prettyPrintJson(params/*, hash*/) {
let cache = [];
debugger;
return JSON.stringify(params[0], function(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return "<replaced>";
}
// Store value in our collection
cache.push(value);
}
return value;
}, 2);
}
export default Ember.Helper.helper(prettyPrintJson);
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('foo', { path: 'foo/:fooId' }, function() {
this.route('bar', { path: 'bar/:barId' }, function() {
this.route('baz', { path: 'baz/:bazId' }, function() {
});
});
});
});
export default Router;
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<pre>
{{#with (-get-dynamic-var "outletState") as |a|}}
{{x-foo object=a depth=5}}
{{/with}}
</pre>
{{link-to 'foo.bar.baz' 'foo.bar.baz' 1 2 3}}
{{#if depth}}BEGIN{{#each-in object as |k v|}}{{k}} {{x-foo object=v depth=depthMinusOne}}{{/each-in}}END{{else}}...{{/if}}
{
"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