Skip to content

Commit 88854a5

Browse files
authored
use gjs in Linking Between Routes guide
Changed the templates from .hbs to .gjs, and added relevant imports. I didn't add the import or <template> when it looked like the example was only showing part of a template.
1 parent 794b3a5 commit 88854a5

File tree

1 file changed

+54
-39
lines changed

1 file changed

+54
-39
lines changed

guides/release/routing/linking-between-routes.md

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ Router.map(function() {
1616
});
1717
```
1818

19-
```handlebars {data-filename=app/templates/photos.hbs}
20-
<ul>
21-
{{#each this.photos as |p|}}
22-
<li>
23-
<LinkTo @route="photos.edit" @model={{p}}>{{p.title}}</LinkTo>
24-
</li>
25-
{{/each}}
26-
</ul>
19+
```handlebars {data-filename=app/templates/photos.gjs}
20+
import { LinkTo } from '@ember/routing';
21+
<template>
22+
<ul>
23+
{{#each this.photos as |p|}}
24+
<li>
25+
<LinkTo @route="photos.edit" @model={{p}}>{{p.title}}</LinkTo>
26+
</li>
27+
{{/each}}
28+
</ul>
29+
</template>
2730
```
2831

2932
The `@route` argument is the name of the route to link to, and the `@model`
@@ -56,7 +59,7 @@ behavior can be customized within `PhotoEditRoute`'s `serialize` hook.
5659
Alternatively, you can explicitly provide a serialized `id`, in place of
5760
passing a model object:
5861

59-
```handlebars {data-filename=app/templates/photos.hbs}
62+
```handlebars {data-filename=app/templates/photos.gjs}
6063
<LinkTo @route="photos.edit" @model="1">First Photo Ever</LinkTo>
6164
```
6265

@@ -93,14 +96,17 @@ will be given the `active` CSS class. For example, if you were at the URL
9396

9497
The CSS class name used for active classes can be customized for a single use of `<LinkTo />` by passing an `@activeClass` argument:
9598

96-
```handlebars {data-filename=app/templates/photos.hbs}
97-
<ul>
98-
{{#each this.photos as |p|}}
99-
<li>
100-
<LinkTo @route="photos.edit" @model={{p}} @activeClass="font-bold">{{p.title}}</LinkTo>
101-
</li>
102-
{{/each}}
103-
</ul>
99+
```handlebars {data-filename=app/templates/photos.gjs}
100+
import { LinkTo } from '@ember/routing';
101+
<template>
102+
<ul>
103+
{{#each this.photos as |p|}}
104+
<li>
105+
<LinkTo @route="photos.edit" @model={{p}} @activeClass="font-bold">{{p.title}}</LinkTo>
106+
</li>
107+
{{/each}}
108+
</ul>
109+
</template>
104110
```
105111

106112
will result in:
@@ -146,12 +152,15 @@ URL.
146152

147153
For example, if we are currently on `/photos/2`, then the following template:
148154

149-
```handlebars {data-filename=app/templates/photos/photo.hbs}
150-
{{#each this.photo.comments as |comment|}}
151-
<LinkTo @route="photos.photo.comment" @model={{comment}}>
152-
{{excerpt comment.body}}...
153-
</LinkTo>
154-
{{/each}}
155+
```handlebars {data-filename=app/templates/photos/photo.gjs}
156+
import { LinkTo } from '@ember/routing';
157+
<template>
158+
{{#each this.photo.comments as |comment|}}
159+
<LinkTo @route="photos.photo.comment" @model={{comment}}>
160+
{{excerpt comment.body}}...
161+
</LinkTo>
162+
{{/each}}
163+
</template>
155164
```
156165

157166
...will render something like this:
@@ -182,18 +191,21 @@ To solve this problem, or maybe to cross-link comments from photos other than
182191
the currently active one, you can pass an array of model objects using the
183192
`@models` argument and the `{{array}}` helper:
184193

185-
```handlebars {data-filename=app/templates/photos.hbs}
186-
<h1>Latest Comments</h1>
187-
188-
<ul>
189-
{{#each this.latestComments as |comment|}}
190-
<li>
191-
<LinkTo @route="photos.photo.comment" @models={{array comment.photo comment}}>
192-
{{excerpt comment.body}}...
193-
</LinkTo>
194-
</li>
195-
{{/each}}
196-
</ul>
194+
```handlebars {data-filename=app/templates/photos.gjs}
195+
import { LinkTo } from '@ember/routing';
196+
<template>
197+
<h1>Latest Comments</h1>
198+
199+
<ul>
200+
{{#each this.latestComments as |comment|}}
201+
<li>
202+
<LinkTo @route="photos.photo.comment" @models={{array comment.photo comment}}>
203+
{{excerpt comment.body}}...
204+
</LinkTo>
205+
</li>
206+
{{/each}}
207+
</ul>
208+
</template>
197209
```
198210

199211
Here, we are passing an array of model objects (the photo, then the comment),
@@ -224,10 +236,13 @@ example, it is quite common to want to add additional CSS classes to the
224236
generated link tag, or specifying the appropriate ARIA attributes. You can
225237
simply pass them along with the invocation:
226238

227-
```handlebars {data-filename=app/templates/photos/edit.hbs}
228-
<LinkTo @route="photos" class="btn btn-primary" role="button" aria-pressed="false">
229-
Discard Changes
230-
</LinkTo>
239+
```handlebars {data-filename=app/templates/photos/edit.gjs}
240+
import { LinkTo } from '@ember/routing';
241+
<template>
242+
<LinkTo @route="photos" class="btn btn-primary" role="button" aria-pressed="false">
243+
Discard Changes
244+
</LinkTo>
245+
</template>
231246
```
232247

233248
CSS classes passed this way will be _in addition to_ the standard `ember-view`

0 commit comments

Comments
 (0)