Last active
May 22, 2018 20:04
-
-
Save GavinJoyce/c93de7ba99cf7df9b3bf8f86171acad9 to your computer and use it in GitHub Desktop.
SPIKE: custom router dsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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