handlebars-helper-range
v1.1.1
Published
Handlebars helper for generating a list of integers
Downloads
1,019
Readme
handlebars-helper-range
A Handlebars helper for generating a range of integer values for block context.
Installation
Install using npm:
$ npm install handlebars-helper-range
Usage
helpers.js
Example helpers file that requires in Handlebars and registers the range helper under the name "range".
var Handlebars = require('handlebars');
Handlebars.registerHelper('range', require('handlebars-helper-range'));
Once registered, templates will have access to the "range" helper which accepts up to three arguments: start (optional, defaults to 0, the start of the range), stop (the end of the range), and step (optional, defaults to 1, the value to increment or decrement by).
Example Templates
templates/example1.handlebars
Example template file that generates the list 0 through 9.
<ul>
{{#range 10}}
<li>{{this}}</li>
{{/range}}
</ul>
templates/example2.handlebars
Example template file that generates the list 1 through 10.
<ul>
{{#range 1 11}}
<li>{{this}}</li>
{{/range}}
</ul>
templates/example3.handlebars
Example template file that generates the list 0, 5, 10, 15.
<ul>
{{#range 0 20 5}}
<li>{{this}}</li>
{{/range}}
</ul>
Changelog
1.1.1
- No changes. Build fix.
1.1.0
- Removed lodash dependency
1.0.0
- Initial release
License
MIT