Skip to content

Instantly share code, notes, and snippets.

@veader
Created September 12, 2013 15:10

Revisions

  1. veader created this gist Sep 12, 2013.
    31 changes: 31 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    // 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.