Want to add and retrieving metadata from Ember routes? I ended up solving this along the following lines, writing my own “route” function which records data I need, then passes it along to the DSL:
1 2 3 4 5 6 7 8 9 | var myRouteData = {}; function route(dsl, name, options, fn) { if (typeof options === 'function') fn = options, options = {}; var routeName = dsl.parent ? dsl.parent + '.' + name : name; myRouteData[routeName] = { options.myRouteOption }; dsl.route(name, options.fn); } |
Usages:
1 2 3 | this.resource('foo', function() { route(this, 'bar', {myRouteOption: true}); }); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.