emberjs / emberjs/rfcs

Spread Operator In Templates

Open
#184 13 comments 6 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
801
Forks
409
PR merge metrics
No merged PRs in 30d

Description

## Problem

Currently there is no way to pass dynamic parameters to certain Template Helpers. I'll call out the `query-params` helper in this case as an example.

Typically we'd use it in the following way:
```
{{#link-to 'route' (query-params sort="asc" status="complete")}}
```
Which would give us a link to `/route?sort=asc&status=complete`

This works well, but there is no way to pass a set of dynamic values to the helper. If we have the following in a component:
```
params: {
sort: 'asc',
status: 'complete'
}
```
You can't destructure the parameters in the template:
```
{{#link-to 'route' (query-params params)}}
```

## Solution
We should add support for a spread operator (similar to the one in javascript) for use in templates.
I would see something like this looking like:
```
{{#link-to 'route (query-params ...params)}}
```
Which would end up being the same as:
```
{{#link-to 'route' (query-params sort="asc" status="complete")}}
```
But would allow us to change `params` and have it reflect in the helper.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.