Skip to content

Commit

Permalink
[DOC beta] each-in docs
Browse files Browse the repository at this point in the history
(cherry picked from commit b573442)
  • Loading branch information
mixonic authored and rwjblue committed Aug 13, 2015
1 parent bcef793 commit a2b5dc8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
36 changes: 36 additions & 0 deletions packages/ember-htmlbars/lib/helpers/each-in.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,43 @@
/**
@module ember
@submodule ember-templates
*/

import isEnabled from 'ember-metal/features';
import shouldDisplay from 'ember-views/streams/should_display';

if (isEnabled('ember-htmlbars-each-in')) {
/**
The `{{each-in}}` helper loops over properties on an object. It is unbound,
in that new (or removed) properties added to the target object will not be
rendered.
For example, given a `user` object that looks like:
```javascript
{
"name": "Shelly Sails",
"age": 42
}
```
This template would display all properties on the `user`
object in a list:
```handlebars
<ul>
{{#each-in user as |key value|}}
<li>{{key}}: {{value}}</li>
{{/each-in}}
</ul>
```
Outputting their name and age.
@method each-in
@for Ember.Templates.helpers
@public
*/
var eachInHelper = function([ object ], hash, blocks) {
var objKeys, prop, i;
objKeys = object ? Object.keys(object) : [];
Expand Down
5 changes: 5 additions & 0 deletions packages/ember-htmlbars/lib/helpers/each.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
@module ember
@submodule ember-templates
*/

import shouldDisplay from 'ember-views/streams/should_display';
import decodeEachKey from 'ember-htmlbars/utils/decode-each-key';

Expand Down

0 comments on commit a2b5dc8

Please sign in to comment.