Skip to content

Commit 24d2db8

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

File tree

2 files changed

+122
-2
lines changed

2 files changed

+122
-2
lines changed

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

+24-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,32 @@ 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+
```
43+
<div>
44+
<h1>Application template!</h1>
45+
{{mount 'admin' model=(hash
46+
title='Secret Admin'
47+
signInButton=(component 'sign-in-button')
48+
)}}
49+
</div>
50+
```
3251
3352
@method mount
53+
@param {String} name Name of the engine to mount.
54+
@param {Object} [model] Object that will be set as
55+
the model of the engine.
3456
@for Ember.Templates.helpers
3557
@category ember-application-engines
3658
@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

0 commit comments

Comments
 (0)