Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation for get helper #1750

Merged
merged 3 commits into from
Dec 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions guides/release/components/helper-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,22 @@ For the full list of available helpers, you can check the [template helpers API
### The `get` helper

The [`{{get}}`](https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/get?anchor=get)
helper makes it easy to dynamically send the value of a variable to another
helper or component. This can be useful if you want to output one of several
values based on the result of a getter.
helper makes it easy to dynamically look up a property on an object or an element in an array. The second argument to `{{get}}` can be a string or a number, depending on the object being accessed.


To access a property on an object with a string key:

```handlebars
{{get this.someObject "object_key"}}
```

To access the first element in an array:

```handlebars
{{get this.someArray 0}}
```

To access a property on an object with a dynamic key:

```handlebars
{{get this.address this.part}}
Expand All @@ -219,6 +232,7 @@ values based on the result of a getter.
If the `part` getter returns "zip", this will display the result of `this.address.zip`.
If it returns "city", you get `this.address.city`.


### The `concat` helper

We mentioned above that helpers can be nested. This can be
Expand Down