Skip to content

Commit

Permalink
blocks not options
Browse files Browse the repository at this point in the history
  • Loading branch information
mixonic committed May 22, 2015
1 parent 78c4865 commit c131fb3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions active/0000-stateful-helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ of the HTMLBars subexpression they are powering. For example, given a helper:
// app/helpers/full-name.js
import Ember from "ember";

export default function full-name(params, hash, options) {
// Note that what is called "options" in other docs is
// called "blocks" here. This terminology should become the
// documented norm.
export default function full-name(params, hash, blocks) {
return params.join(' ');
}
```
Expand Down Expand Up @@ -215,28 +218,28 @@ written like so:
import Ember from "ember";

// Usage: {{if-is-yes 'no'}}not rendered{{else}}rendered!{{/if-is-yes}}
export default function ifIsYes(params, hash, options) {
export default function ifIsYes(params, hash, blocks) {
if (params[0] === 'yes') {
options.template.yield();
blocks.template.yield();
} else {
options.inverse.yield();
blocks.inverse.yield();
}
};
```

Porting this usage to a stateful helper only changes the boilerplate:

```
```js
// app/helpers/custom-if.js
import Ember from "ember";

// Usage: {{if-is-yes 'no'}}not rendered{{else}}rendered!{{/if-is-yes}}
export default Ember.Helper.extend({
compute(params, hash, options) {
compute(params, hash, blocks) {
if (params[0]) {
options.template.yield();
blocks.template.yield();
} else {
options.inverse.yield();
blocks.inverse.yield();
}
}
});
Expand Down

0 comments on commit c131fb3

Please sign in to comment.