Nested routes of arbitrary-depth


#1

Is there a way to express nested routes of arbitrary-depth in ember’s router?

Suppose you want to implement a directory browser: a directory tree is on the top page and you can move around the tree by clicking one of the nodes. When you click, it shows the description about the node such as name and size etc.

A natural way to encode this application in ember.js is that to use nested routes of arbitrary-depth but I couldn’t find a way to do it.

Any thoughts?


#2

Ember supports route globbing.

this.route('browse', { path: 'files/*files' });

Then, in your route you’ll get an array in the files attribute on params.


Customize the url in ember.js apps?
#3

Thanks! I didn’t know that.


#4

@blatyo I’m unable to reproduce your example in RC7 and I can’t find any reference to route globbing in the documentation, source code, github issues, or google. Maybe I’m just not looking hard enough?

Update: Apparently my ‘catchAll’ route was overriding the ‘browse’ route.

this.route('catchAll', { path: '*:' });

Sorry I doubted you @blatyo. Hopefully globbing will be documented in the 1.0 router guide.


#5

Does anybody know if this is still possible in Ember 1.2+? I’ve tried this construction (and numerous others) and keep getting an error like: Uncaught SyntaxError: <unknown message reserved_word>. My route looks like:

@route 'import_from_image', path: '/import_from_image/*somepath'