diff --git a/source/routing/defining-your-routes.md b/source/routing/defining-your-routes.md index 3b6dce226..05e6ffb4a 100644 --- a/source/routing/defining-your-routes.md +++ b/source/routing/defining-your-routes.md @@ -198,6 +198,96 @@ Visiting `/posts` is slightly different. It will first render the Finally, visiting `/posts/new` will first render the `posts` template, then render the `posts/new` template into its outlet. +#### Resetting Nested Route Namespace + +When nesting routes, it may be beneficial for a child route to not inherit its ancestors name. This allows you to reference and reuse a given route in multiple route trees as well as keep the class name short. This is equivalent to the behavior of the now deprecated `this.resource()` function. + +You can reset the current "namespace" with the aptly named `resetNamespace: true` option. + +```app/router.js +Router.map(function() { + this.route('post', { path: '/post/:post_id' }, function() { + this.route('edit'); + this.route('comments', { resetNamespace: true }, function() { + this.route('new'); + }); + }); +}); +``` + +This router creates five routes: + +
URL | +Route Name | +Controller | +Route | +Template | +
---|---|---|---|---|
/ |
+ index |
+ app/controllers/index |
+ app/routes/index |
+ app/templates/index |
+
N/A | +post |
+ app/controllers/post |
+ app/routes/post |
+ app/templates/post |
+
/post/:post_id2 |
+ post.index |
+ app/controllers/post/index |
+ app/routes/post/index |
+ app/templates/post/index |
+
/post/:post_id/edit |
+ post.edit |
+ app/controllers/post/edit |
+ app/routes/post/edit |
+ app/templates/post/edit |
+
N/A | +comments |
+ app/controllers/comments |
+ app/routes/comments |
+ app/templates/comments |
+
/post/:post_id/comments |
+ comments.index |
+ app/controllers/comments/index |
+ app/routes/comments/index |
+ app/templates/comments/index |
+
/post/:post_id/comments/new |
+ comments.new |
+ app/controllers/comments/new |
+ app/routes/comments/new |
+ app/templates/comments/new |
+