hpwp-para

Allow named parameters to be passed to handlebars partials.


Keywords
marionette, controller, region
License
MIT
Install
bower install hpwp-para

Documentation

handlebars.partialsWithParameters

Brought to you by Use All Five, Inc.

Author: Justin Anastos <janastos@useallfive.com>
Author URI: [http://www.useallfive.com](http://www.useallfive.com)
Repository: https://github.com/UseAllFive/handlebars.partialsWithParameters

Allow named parameters to be passed to handlebars partials.

Annotated Source

Installation

  • Include lib/handlebars.partialsWithParameters.js before any partials to which you need to pass parameters are rendered.

Usage

  1. Define the Handlebars partial in your JavaScript:

    Handlebars.registerPartial('partialName', partialTemplate);
  2. Call the custom helper created by this module, $, in your template. Note that the partial name must be quoted and sent as a string to the helper.

    {{$ 'partialeName' param1='value1' param2='value2'}}
  3. Use the parameters values by accessing the hash property added to the context of the partial template.

    Partial should be defined like this:

    <div class="test-class">{{ hash.param1 }}</div>
    <div class="test-class">{{ hash.param2 }}</div>

    The output will look like this:

    <div class="test-class">value1</div>
    <div class="test-class">value2</div>