diff --git a/src/pages/block_helpers.haml b/src/pages/block_helpers.haml index ed5ed93..1393cf9 100644 --- a/src/pages/block_helpers.haml +++ b/src/pages/block_helpers.haml @@ -376,6 +376,30 @@ {{/each}} {{/each}} + .bullet + .description + A number of builtin helpers support block parameters and any custom helper may provide them through the blockParams options field. + + :javascript + Handlebars.registerHelper('block-params', function() { + var args = [], + options = arguments[arguments.length - 1]; + for (var i = 0; i < arguments.length - 1; i++) { + args.push(arguments[i]); + } + + return options.fn(this, {data: options.data, blockParams: args}); + }); + :html + {{#block-params 1 2 3 as |foo bar baz|}} + {{foo}} {{bar}} {{baz}} + {{/block-params}} + + .notes + Implements a helper that allows for named variable declarations within a given block. This example would output 1 2 3 on render. + + .notes + Helpers can determine the number of block paramemters referenced by the template via the options.fn.blockParams field, which is an integer count. This value represents the number of block parameters that could be referenced by the child template. Parameters beyond this cound will never be referenced and can safely be omitted by the helper if desired. This is optional and any additional parameters passed to the template will be silently ignored. %h2#raw-blocks Raw Blocks