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

[DOC] Document get helper array element access with second arg of type number #19871

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
18 changes: 16 additions & 2 deletions packages/@ember/-internals/glimmer/lib/helpers/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
*/

/**
Dynamically look up a property on an object. The second argument to `{{get}}`
should have a string value, although it can be bound.
Dynamically look up a property on an object or an element in an array.
The second argument to `{{get}}` should have a string or number value,
although it can be bound.

For example, these two usages are equivalent:

Expand Down Expand Up @@ -77,6 +78,19 @@
Would allow the user to swap what fact is being displayed, and also edit
that fact via a two-way mutable binding.

The `{{get}}` helper can also be used for array element access via index.
This would display the value of the first element in the array `this.names`:

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

Array element access also works with a dynamic second argument:

```handlebars
{{get this.names @index}}
```

@public
@method get
@for Ember.Templates.helpers
Expand Down