-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
hash.ts
48 lines (38 loc) · 1.04 KB
/
hash.ts
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
37
38
39
40
41
42
43
44
45
46
47
48
import { Arguments, VM } from '@glimmer/runtime';
/**
@module ember
*/
/**
Use the `{{hash}}` helper to create a hash to pass as an option to your
components. This is specially useful for contextual components where you can
just yield a hash:
```handlebars
{{yield (hash
name='Sarah'
title=office
)}}
```
Would result in an object such as:
```js
{ name: 'Sarah', title: this.get('office') }
```
Where the `title` is bound to updates of the `office` property.
Note that the hash is an empty object with no prototype chain, therefore
common methods like `toString` are not available in the resulting hash.
If you need to use such a method, you can use the `call` or `apply`
approach:
```js
function toString(obj) {
return Object.prototype.toString.apply(obj);
}
```
@method hash
@for Ember.Templates.helpers
@param {Object} options
@return {Object} Hash
@since 2.3.0
@public
*/
export default function(_vm: VM, args: Arguments) {
return args.named.capture();
}