-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
query-param.js
36 lines (30 loc) · 1.04 KB
/
query-param.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
@module ember
@submodule ember-glimmer
*/
import { assign } from 'ember-utils';
import { InternalHelperReference } from '../utils/references';
import { assert } from 'ember-metal';
import { QueryParams } from 'ember-routing';
/**
This is a helper to be used in conjunction with the link-to helper.
It will supply url query parameters to the target route.
Example
```handlebars
{{#link-to 'posts' (query-params direction="asc")}}Sort{{/link-to}}
```
@method query-params
@for Ember.Templates.helpers
@param {Object} hash takes a hash of query parameters
@return {Object} A `QueryParams` object for `{{link-to}}`
@public
*/
function queryParams({ positional, named }) {
assert('The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName=\'foo\') as opposed to just (query-params \'foo\')', positional.value().length === 0);
return QueryParams.create({
values: assign({}, named.value())
});
}
export default function(vm, args) {
return new InternalHelperReference(queryParams, args);
}