Skip to content

Commit

Permalink
[DOC release] Improve documentation for RouterService and mount helper
Browse files Browse the repository at this point in the history
Fixes #15622
  • Loading branch information
locks committed Sep 18, 2017
1 parent 9654d2a commit 24d2db8
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 2 deletions.
26 changes: 24 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,32 @@ 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

0 comments on commit 24d2db8

Please sign in to comment.