Skip to content

Commit d59d321

Browse files
committed
Document get helper array element access with a number
1 parent 703b9ca commit d59d321

File tree

1 file changed

+16
-2
lines changed
  • packages/@ember/-internals/glimmer/lib/helpers

1 file changed

+16
-2
lines changed

packages/@ember/-internals/glimmer/lib/helpers/get.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
*/
44

55
/**
6-
Dynamically look up a property on an object. The second argument to `{{get}}`
7-
should have a string value, although it can be bound.
6+
Dynamically look up a property on an object or an element in an array.
7+
The second argument to `{{get}}` should have a string or number value,
8+
although it can be bound.
89
910
For example, these two usages are equivalent:
1011
@@ -77,6 +78,19 @@
7778
Would allow the user to swap what fact is being displayed, and also edit
7879
that fact via a two-way mutable binding.
7980
81+
The `{{get}}` helper can also be used for array element access via index.
82+
This would display the value of the first element in the array `this.names`:
83+
84+
```handlebars
85+
{{get this.names 0}}
86+
```
87+
88+
Array element access also works with a dynamic second argument:
89+
90+
```handlebars
91+
{{get this.names @index}}
92+
```
93+
8094
@public
8195
@method get
8296
@for Ember.Templates.helpers

0 commit comments

Comments
 (0)