Skip to content

Commit c253239

Browse files
MahemaS27jamescdavisijlee2
authored
Update documentation for get helper (#1750)
* update get helper with string & integer use * Apply suggestions from code review Co-authored-by: James C. Davis <jamescdavis@gmail.com> * Apply suggestions from code review Co-authored-by: Isaac Lee <16869656+ijlee2@users.noreply.github.com> Co-authored-by: James C. Davis <jamescdavis@gmail.com> Co-authored-by: Isaac Lee <16869656+ijlee2@users.noreply.github.com>
1 parent 2aa3339 commit c253239

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

guides/release/components/helper-functions.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,22 @@ For the full list of available helpers, you can check the [template helpers API
208208
### The `get` helper
209209

210210
The [`{{get}}`](https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/get?anchor=get)
211-
helper makes it easy to dynamically send the value of a variable to another
212-
helper or component. This can be useful if you want to output one of several
213-
values based on the result of a getter.
211+
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.
212+
213+
214+
To access a property on an object with a string key:
215+
216+
```handlebars
217+
{{get this.someObject "object_key"}}
218+
```
219+
220+
To access the first element in an array:
221+
222+
```handlebars
223+
{{get this.someArray 0}}
224+
```
225+
226+
To access a property on an object with a dynamic key:
214227

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

235+
222236
### The `concat` helper
223237

224238
We mentioned above that helpers can be nested. This can be

0 commit comments

Comments
 (0)