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.
- Include
lib/handlebars.partialsWithParameters.js
before any partials to which you need to pass parameters are rendered.
-
Define the Handlebars partial in your JavaScript:
Handlebars.registerPartial('partialName', partialTemplate);
-
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. -
Use the parameters values by accessing the
hash
property added to the context of the partial template.Partial should be defined like this:
The output will look like this:
<div class="test-class">value1</div> <div class="test-class">value2</div>