From c131fb326ccaa75ee2c48e94f4a31226cbc3eff0 Mon Sep 17 00:00:00 2001 From: Matthew Beale Date: Fri, 22 May 2015 10:13:09 -0400 Subject: [PATCH] blocks not options --- active/0000-stateful-helpers.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/active/0000-stateful-helpers.md b/active/0000-stateful-helpers.md index 98ecd8011a..0e9dda85a3 100644 --- a/active/0000-stateful-helpers.md +++ b/active/0000-stateful-helpers.md @@ -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(' '); } ``` @@ -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(); } } });