Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC release] Improve documentation for RouterService and mount helper #15616

Merged
merged 1 commit into from
Oct 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions packages/ember-glimmer/lib/syntax/mount.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,31 @@ function dynamicEngineFor(vm, args, meta) {
{{mount "ember-chat"}}
```

Currently, the engine name is the only argument that can be passed to
`{{mount}}`.
Additionally, you can also pass in a `model` argument that will be
set as the engines model. This can be an existing object:

```
<div>
{{mount 'admin' model=userSettings}}
</div>
```

Or an inline `hash`, and you can even pass components:

```
<div>
<h1>Application template!</h1>
{{mount 'admin' model=(hash
title='Secret Admin'
signInButton=(component 'sign-in-button')
)}}
</div>
```

@method mount
@param {String} name Name of the engine to mount.
@param {Object} [model] Object that will be set as
the model of the engine.
@for Ember.Templates.helpers
@category ember-application-engines
@public
Expand Down
98 changes: 98 additions & 0 deletions packages/ember-routing/lib/services/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,107 @@ import { shallowEqual } from '../utils';
@category ember-routing-router-service
*/
const RouterService = Service.extend({

/**
Name of the current route.

This property represent the logical name of the route,
which is comma separated.
For the following router:

```app/router.js
Router.map(function() {
this.route('about);
this.route('blog', function () {
this.route('post', { path: ':post_id' });
});
});
```

It will return:

* `index` when you visit `/`
* `about` when you visit `/about`
* `blog.index` when you visit `/blog`
* `blog.post` when you visit `/blog/some-post-id`

@property currentRouteName
@type String
@public
*/
currentRouteName: readOnly('_router.currentRouteName'),

/**
Current URL for the application.

This property represent the URL path for this route.
For the following router:

```app/router.js
Router.map(function() {
this.route('about);
this.route('blog', function () {
this.route('post', { path: ':post_id' });
});
});
```

It will return:

* `/` when you visit `/`
* `/about` when you visit `/about`
* `/blog/index` when you visit `/blog`
* `/blog/post` when you visit `/blog/some-post-id`

@property currentURL
@type String
@public
*/
currentURL: readOnly('_router.currentURL'),

/**
The `location` property determines the type of URL's that your
application will use.
The following location types are currently available:
* `auto`
* `hash`
* `history`
* `none`

@property location
@default 'hash'
@see {Ember.Location}
@public
*/
location: readOnly('_router.location'),

/**
The `rootURL` property represents the URL of the root of
the application, '/' by default.
This prefix is assumed on all routes defined on this app.

IF you change the `rootURL` in your environment configuration
like so:

```config/environment.js
'use strict';

module.exports = function(environment) {
let ENV = {
modulePrefix: 'router-service',
environment,
rootURL: '/my-root',
}
]
```

This property will return `/my-root`.

@property rootURL
@default '/'
@public
*/
rootURL: readOnly('_router.rootURL'),
_router: null,

Expand Down
2 changes: 1 addition & 1 deletion packages/ember-routing/lib/system/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const EmberRouter = EmberObject.extend(Evented, {
* `none` - do not store the Ember URL in the actual browser URL (mainly used for testing)
* `auto` - use the best option based on browser capabilities: `history` if possible, then `hash` if possible, otherwise `none`

Note: If using ember-cli, this value is defaulted to `auto` by the `locationType` setting of `/config/environment.js`
This value is defaulted to `auto` by the `locationType` setting of `/config/environment.js`

@property location
@default 'hash'
Expand Down