Skip to content

Instantly share code, notes, and snippets.

@veader
Created September 12, 2013 15:10
Show Gist options
  • Save veader/6539106 to your computer and use it in GitHub Desktop.
Save veader/6539106 to your computer and use it in GitHub Desktop.
Ember Routing Fun
// these are the routes I'd like to define
//
// /posts (load all posts)
// /posts/all (only here for completeness)
// /posts/archived (load only archived posts)
// /posts/unpublished (load only unpublished posts)
// /posts/1 (load individual post)
// the only way I can see doing it in Ember at this point (1.0)
App.Router.map({
this.resource('posts', function () {
this.route('archived', { path: '/archived' });
this.route('unpublished', { path: '/unpublished' });
this.resource('post', { path: '/:post_id' });
});
});
// this involves a lot of junk code and is still tricky to have the App.PostsController
// being the one fetching and the 'posts' template doing the rendering.
// what I'd love to see is something like this
App.Route.map({
this.resource('posts'
, { path: '/:filter', allow_blank: true, values: 'all archived unpublished'.w()}
, function () {
this.resource('post', { path: '/:post_id'})
})
});
// I'm still digging into the Router code to see if this is even possible.
// Am I working at this problem the wrong way? Any help would be appreciated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment