Skip to content

Commit b8e786c

Browse files
committed
[DOC release] Improve documentation for RouterService and mount helper
Fixes #15622
1 parent 9654d2a commit b8e786c

File tree

3 files changed

+122
-3
lines changed

3 files changed

+122
-3
lines changed

packages/ember-glimmer/lib/syntax/mount.js

+23-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,31 @@ function dynamicEngineFor(vm, args, meta) {
2727
{{mount "ember-chat"}}
2828
```
2929
30-
Currently, the engine name is the only argument that can be passed to
31-
`{{mount}}`.
30+
Additionally, you can also pass in a `model` argument that will be
31+
set as the engines model. This can be an existing object:
32+
33+
```
34+
<div>
35+
{{mount 'admin' model=userSettings}}
36+
</div>
37+
```
38+
39+
Or an inline `hash`, and you can even pass components:
40+
41+
```
42+
<div>
43+
<h1>Application template!</h1>
44+
{{mount 'admin' model=(hash
45+
title='Secret Admin'
46+
signInButton=(component 'sign-in-button')
47+
)}}
48+
</div>
49+
```
3250
3351
@method mount
52+
@param {String} name Name of the engine to mount.
53+
@param {Object} [model] Object that will be set as
54+
the model of the engine.
3455
@for Ember.Templates.helpers
3556
@category ember-application-engines
3657
@public

packages/ember-routing/lib/services/router.js

+98
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,107 @@ import { shallowEqual } from '../utils';
1818
@category ember-routing-router-service
1919
*/
2020
const RouterService = Service.extend({
21+
22+
/**
23+
Name of the current route.
24+
25+
This property represent the logical name of the route,
26+
which is comma separated.
27+
For the following router:
28+
29+
```app/router.js
30+
Router.map(function() {
31+
this.route('about);
32+
this.route('blog', function () {
33+
this.route('post', { path: ':post_id' });
34+
});
35+
});
36+
```
37+
38+
It will return:
39+
40+
* `index` when you visit `/`
41+
* `about` when you visit `/about`
42+
* `blog.index` when you visit `/blog`
43+
* `blog.post` when you visit `/blog/some-post-id`
44+
45+
@property currentRouteName
46+
@type String
47+
@public
48+
*/
2149
currentRouteName: readOnly('_router.currentRouteName'),
50+
51+
/**
52+
Current URL for the application.
53+
54+
This property represent the URL path for this route.
55+
For the following router:
56+
57+
```app/router.js
58+
Router.map(function() {
59+
this.route('about);
60+
this.route('blog', function () {
61+
this.route('post', { path: ':post_id' });
62+
});
63+
});
64+
```
65+
66+
It will return:
67+
68+
* `/` when you visit `/`
69+
* `/about` when you visit `/about`
70+
* `/blog/index` when you visit `/blog`
71+
* `/blog/post` when you visit `/blog/some-post-id`
72+
73+
@property currentURL
74+
@type String
75+
@public
76+
*/
2277
currentURL: readOnly('_router.currentURL'),
78+
79+
/**
80+
The `location` property determines the type of URL's that your
81+
application will use.
82+
The following location types are currently available:
83+
* `auto`
84+
* `hash`
85+
* `history`
86+
* `none`
87+
88+
@property location
89+
@default 'hash'
90+
@see {Ember.Location}
91+
@public
92+
*/
2393
location: readOnly('_router.location'),
94+
95+
/**
96+
The `rootURL` property represents the URL of the root of
97+
the application, '/' by default.
98+
This prefix is assumed on all routes defined on this app.
99+
100+
IF you change the `rootURL` in your environment configuration
101+
like so:
102+
103+
```config/environment.js
104+
'use strict';
105+
106+
module.exports = function(environment) {
107+
let ENV = {
108+
modulePrefix: 'router-service',
109+
environment,
110+
rootURL: '/my-root',
111+
112+
}
113+
]
114+
```
115+
116+
This property will return `/my-root`.
117+
118+
@property rootURL
119+
@default '/'
120+
@public
121+
*/
24122
rootURL: readOnly('_router.rootURL'),
25123
_router: null,
26124

packages/ember-routing/lib/system/router.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const EmberRouter = EmberObject.extend(Evented, {
7373
* `none` - do not store the Ember URL in the actual browser URL (mainly used for testing)
7474
* `auto` - use the best option based on browser capabilities: `history` if possible, then `hash` if possible, otherwise `none`
7575
76-
Note: If using ember-cli, this value is defaulted to `auto` by the `locationType` setting of `/config/environment.js`
76+
This value is defaulted to `auto` by the `locationType` setting of `/config/environment.js`
7777
7878
@property location
7979
@default 'hash'

0 commit comments

Comments
 (0)