handlebars-plugin-grouping

1.0.1 • Public • Published

handlebars-plugin-grouping

A handlebars grouping iterator plugin to group collections into groups of definable size.

Template Usage

An example template to render a collection of thumbnails into a bootstrap grid row of 6 thumbnails per row.

{{#grouping thumbnails 6}}
<div class="row">
    <div class="row-fluid" title="Row {{@index}} of {{@groups}} contains {{@size}} thumbnails.">
        {{#each this}}
            <div class="col-md-2">
                <img id="thumbnail-{{id}}" src="{{src}}" title="{{title}}"/>
            </div>
        {{/each}}
    </div>
</div>
{{/grouping}}

Node.js

Installation:

npm install handlebars-plugin-grouping --save

Example:

var grouping = require('handlebars-plugin-grouping');
var exphbs  = require('express-handlebars');
 
var hbs = exphbs.create({
    helpers: {
        grouping: grouping
    }
});

Browser

Load the script after the handlebars runtime.

<script type="text/javascript" src=".../handlebars.runtime.js"></script>
<script type="text/javascript" src=".../handlebars-plugin-grouping.js"></script>

License MIT

Package Sidebar

Install

npm i handlebars-plugin-grouping

Weekly Downloads

11

Version

1.0.1

License

MIT

Last publish

Collaborators

  • dhollenbeck