Skip to content

Instantly share code, notes, and snippets.

@GavinJoyce
Last active May 22, 2018 20:04
Show Gist options
  • Save GavinJoyce/c93de7ba99cf7df9b3bf8f86171acad9 to your computer and use it in GitHub Desktop.
Save GavinJoyce/c93de7ba99cf7df9b3bf8f86171acad9 to your computer and use it in GitHub Desktop.
SPIKE: custom router dsl
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL,
//extend the router dsl to support this.slide(...)
_buildDSL() {
let dsl = this._super(...arguments);
dsl.__proto__.slide = function() {
//TODO: GJ: setup slide map here
console.log('slide', arguments);
dsl.__proto__.route.apply(this, arguments);
}
return dsl;
}
});
Router.map(function() {
//we can use this.slide to define a slide hierarchy, much like this.route
this.slide('slide-1', { title: 'Slide 1' }, function() {
this.slide('sub-1', { title: 'Subslide 1' });
this.slide('sub-2', { title: 'Subslide 2' });
});
this.slide('slide-2', { title: 'Slide 2' });
});
export default Router;
Spike: can we extend the routes.js DSL to support `this.slide`?
<br>
Spoiler: Yes (look at console output)
{
"version": "0.13.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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment