Skip to content

Commit

Permalink
[BUGFIX beta] Add additional documentation on resetNamespace and othe…
Browse files Browse the repository at this point in the history
…r options for this.route()
  • Loading branch information
jayphelps committed Jun 22, 2015
1 parent 78c22ee commit b6d70b0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/ember-routing/lib/system/dsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ DSL.prototype = {
options = {};
}

var type = options.resetNamespace === true ? 'resource' : 'route';
Ember.assert(
`'${name}' cannot be used as a ${type} name.`,
`'${name}' cannot be used as a route name.`,
(function() {
if (options.overrideNameAssertion === true) { return true; }

Expand Down
28 changes: 25 additions & 3 deletions packages/ember-routing/lib/system/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,14 +921,36 @@ EmberRouter.reopenClass({
in your application. These mappings are defined within the
supplied callback function using `this.route`.
The first parameter is the name of the route which is used by default as the
path name as well.
The second parameter is the optional options hash. Available options are:
* `path`: allows you to provide your own path as well as mark dynamic
segments.
* `resetNamespace`: false by default; when nesting routes, ember will
combine the route names to form the fully-qualified route name, which is
used with `{{link-to}}` or manually transitioning to routes. Setting
`resetNamespace: true` will cause the route not to inherit from its
parent route's names. This is handy for resources which can be accessed
in multiple places as well as preventing extremely long route names.
Keep in mind that the actual URL path behavior is still retained.
The third parameter is a function, which can be used to nest routes.
Nested routes, by default, will have the parent route tree's route name and
path prepended to it's own.
```javascript
App.Router.map(function(){
this.route('about');
this.route('article', { resetNamespace: true });
this.route('post', { path: '/post/:post_id' }, function() {
this.route('edit');
this.route('comments', { resetNamespace: true }, function() {
this.route('new');
});
});
});
```
For more detailed examples please see
For more detailed documentation and examples please see
[the guides](http://emberjs.com/guides/routing/defining-your-routes/).
@method map
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-routing/tests/system/dsl_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ QUnit.test('should fail when using a reserved route name', function() {

var router = Router.create();
router._initRouterJs();
}, `'${reservedName}' cannot be used as a resource name.`);
}, `'${reservedName}' cannot be used as a route name.`);

});
});
Expand Down

0 comments on commit b6d70b0

Please sign in to comment.