handlebars-helper-range

1.1.1 • Public • Published

handlebars-helper-range

A Handlebars helper for generating a range of integer values for block context.

npm Version Build Status Test Coverage Dependency Status

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

Readme

Keywords

Package Sidebar

Install

npm i handlebars-helper-range

Weekly Downloads

277

Version

1.1.1

License

MIT

Unpacked Size

8.11 kB

Total Files

9

Last publish

Collaborators

  • jimf