diff --git a/guides/release/routing/linking-between-routes.md b/guides/release/routing/linking-between-routes.md index f422c27473..744df6c6c4 100644 --- a/guides/release/routing/linking-between-routes.md +++ b/guides/release/routing/linking-between-routes.md @@ -16,14 +16,17 @@ Router.map(function() { }); ``` -```handlebars {data-filename=app/templates/photos.hbs} - +```gjs {data-filename=app/templates/photos.gjs} +import { LinkTo } from '@ember/routing'; + ``` 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. Alternatively, you can explicitly provide a serialized `id`, in place of passing a model object: -```handlebars {data-filename=app/templates/photos.hbs} +```gjs {data-filename=app/templates/photos.gjs} First Photo Ever ``` @@ -93,14 +96,17 @@ will be given the `active` CSS class. For example, if you were at the URL The CSS class name used for active classes can be customized for a single use of `` by passing an `@activeClass` argument: -```handlebars {data-filename=app/templates/photos.hbs} - +```gjs {data-filename=app/templates/photos.gjs} +import { LinkTo } from '@ember/routing'; + ``` will result in: @@ -146,12 +152,15 @@ URL. For example, if we are currently on `/photos/2`, then the following template: -```handlebars {data-filename=app/templates/photos/photo.hbs} -{{#each this.photo.comments as |comment|}} - - {{excerpt comment.body}}... - -{{/each}} +```gjs {data-filename=app/templates/photos/photo.gjs} +import { LinkTo } from '@ember/routing'; + ``` ...will render something like this: @@ -182,18 +191,29 @@ To solve this problem, or maybe to cross-link comments from photos other than the currently active one, you can pass an array of model objects using the `@models` argument and the `{{array}}` helper: -```handlebars {data-filename=app/templates/photos.hbs} -

Latest Comments

- - +```gjs {data-filename=app/templates/photos.gjs} +import { LinkTo } from '@ember/routing'; +import { array } from '@ember/helper'; + +export default class { + get latestComments() { + return this.model.sort((a, b) => new Date(b.date) - new Date(a.date)).slice(0, 5); + } +} + + ``` Here, we are passing an array of model objects (the photo, then the comment), @@ -207,7 +227,7 @@ argument. Therefore, it is an error to pass _both_ arguments at the same time. The `@query` argument, along with the `{{hash}}` helper, can be used to set query params on a link: -```handlebars +```gjs // Explicitly set target query params Sort @@ -224,10 +244,13 @@ example, it is quite common to want to add additional CSS classes to the generated link tag, or specifying the appropriate ARIA attributes. You can simply pass them along with the invocation: -```handlebars {data-filename=app/templates/photos/edit.hbs} - - Discard Changes - +```gjs {data-filename=app/templates/photos/edit.gjs} +import { LinkTo } from '@ember/routing'; + ``` CSS classes passed this way will be _in addition to_ the standard `ember-view` @@ -240,7 +263,7 @@ browser's history when transitioning between routes. However, to replace the current entry in the browser's history instead, you can use the `@replace` option: -```handlebars +```gjs Top comment for the current photo