# handlebars-group-every

> Group every N items helpers for handlebars and express

Latest version **1.0.1** (published 2017-01-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install handlebars-group-every
pnpm add handlebars-group-every
yarn add handlebars-group-every
bun add handlebars-group-every
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-01-10 |
| First published | 2017-01-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Stavros Tsourlidakis |
| Maintainers | stsourlidakis |
| Keywords | handlebars, express, group, every, helper |

## Links

- npm: https://www.npmjs.com/package/handlebars-group-every
- Repository: https://github.com/stsourlidakis/handlebars-group-every
- Homepage: https://github.com/stsourlidakis/handlebars-group-every#readme
- Issues: https://github.com/stsourlidakis/handlebars-group-every/issues
- npm.io page: https://npm.io/package/handlebars-group-every

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-01-10
- 1.0.0 — 2017-01-10

## README

# handlebars-group-every
Helpers for handlebars and express to conditionally render open and closing tags in order to group list items

## Installation
With npm
```bash
npm install handlebars-group-every
```
### Or
Copy the functions from [index.js](https://github.com/stsourlidakis/handlebars-group-every/blob/master/index.js) and add them to your helpers object
```javascript
var hbs = exphbs.create({
	defaultLayout: 'main',
	partialsDir: ['views/partials/'],
	helpers: {
		ifGroupEveryOpen: function (index, every, options) {
			if( index%every === 0 ){
				return options.fn(this);
			} else {
				return options.inverse(this);
			}
		},
		ifGroupEveryClose: function (index, every, options) {
			if( options.data.last || (index + 1)%every === 0 ){
				return options.fn(this);
			} else {
				return options.inverse(this);
			}
		}
	}
});
```

## Usage
### With [Express Handlebars](https://github.com/ericf/express-handlebars)
```javascript
const groupEvery = require('handlebars-group-every');

hbs.handlebars.registerHelper('ifGroupEveryOpen', groupEvery.ifGroupEveryOpen);
hbs.handlebars.registerHelper('ifGroupEveryClose', groupEvery.ifGroupEveryClose);
```

```handlebars
<!-- will wrap every 3 items in <div class="row"> </div> -->
{{#each listItems}}
	{{#ifGroupEveryOpen @index 3}}
	<div class="row">
	{{/ifGroupEveryOpen}}
	
		<div class="col-md-4">{{this}}</div>

	{{#ifGroupEveryClose @index 3}}
	</div>
	{{/ifGroupEveryClose}}
{{/each}}
```

---
_Source: https://npm.io/package/handlebars-group-every · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
