Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

handlebars-helper-repeat

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

handlebars-helper-repeat - npm Package Compare versions

Comparing version 0.3.1 to 1.0.0

52

index.js

@@ -14,45 +14,33 @@ /*!

module.exports = function repeat(n, options) {
/* jshint validthis: true */
var hasNumber = isNumber(n);
var context = {};
var self = this;
var isNum = isNumber(n);
if (!hasNumber) {
if (!isNum) {
options = n;
n = 0;
}
if (self && self.context) {
merge(self, self.context);
}
options = options || {};
var opts = merge({count: n}, options, options.hash);
var ctx = this.context
? merge({}, this.context, opts)
: merge({}, this, opts);
if (options.hasOwnProperty('hash')) {
merge(options, options.hash);
if (opts.count) {
return block(ctx);
}
if (options.count) {
n = options.count;
hasNumber = true;
}
return options.inverse(ctx);
};
merge(options, self, context);
if (hasNumber) {
return block(options);
} else {
return options.inverse(options);
}
function block(options) {
var max = options.count;
var str = '';
function block(opts) {
opts = opts || {};
var str = '';
var start = options.start || 0;
var hash = opts.hash || {};
hash.start = hash.start || 0;
for (var i = hash.start; i < n + hash.start; i++) {
hash.index = i;
str += opts.fn(opts, {data: hash});
}
return str;
for (var i = start; i < (max + start); i++) {
var data = merge({index: i}, options);
str += options.fn(options, {data: data});
}
return str;
}
{
"name": "handlebars-helper-repeat",
"description": "Handlebars block helper for repeating whatever is inside the block `n` number of times.",
"version": "0.3.1",
"description": "Handlebars block helper for repeating whatever is inside the block _n_ times.",
"version": "1.0.0",
"homepage": "https://github.com/helpers/handlebars-helper-repeat",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"repository": {
"type": "git",
"url": "https://github.com/helpers/handlebars-helper-repeat.git"
},
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "helpers/handlebars-helper-repeat",
"bugs": {
"url": "https://github.com/helpers/handlebars-helper-repeat/issues"
},
"license": {
"type": "MIT",
"url": "https://github.com/helpers/handlebars-helper-repeat/blob/master/LICENSE"
},
"license": "MIT",
"files": [

@@ -25,12 +16,15 @@ "index.js"

"main": "index.js",
"engines": {
"node": ">= 0.10.0"
},
"dependencies": {
"is-number": "^1.1.2",
"mixin-deep": "^1.0.1"
"is-number": "^3.0.0",
"mixin-deep": "^1.1.3"
},
"devDependencies": {
"engine-handlebars": "^0.6.1",
"handlebars": "^3.0.0",
"mocha": "^2.2.1",
"should": "^5.2.0",
"template": "^0.11.1"
"engine-handlebars": "^0.8.0",
"gulp-format-md": "^0.1.11",
"handlebars": "^4.0.6",
"mocha": "^3.2.0",
"templates": "^0.25.3"
},

@@ -40,7 +34,34 @@ "keywords": [

"assemblehelper",
"handlebars",
"handlebars helper",
"helper",
"helpers",
"render",
"repeat",
"handlebars",
"handlebars helper"
]
"template",
"templates"
],
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"related": {
"list": [
"handlebars-helpers",
"template-helpers"
]
},
"reflinks": [
"verb",
"verb-generate-readme"
],
"lint": {
"reflinks": true
}
}
}

@@ -1,13 +0,15 @@

# handlebars-helper-repeat [![NPM version](https://badge.fury.io/js/handlebars-helper-repeat.svg)](http://badge.fury.io/js/handlebars-helper-repeat) [![Build Status](https://travis-ci.org/helpers/handlebars-helper-repeat.svg)](https://travis-ci.org/helpers/handlebars-helper-repeat)
# handlebars-helper-repeat [![NPM version](https://img.shields.io/npm/v/handlebars-helper-repeat.svg?style=flat)](https://www.npmjs.com/package/handlebars-helper-repeat) [![NPM monthly downloads](https://img.shields.io/npm/dm/handlebars-helper-repeat.svg?style=flat)](https://npmjs.org/package/handlebars-helper-repeat) [![NPM total downloads](https://img.shields.io/npm/dt/handlebars-helper-repeat.svg?style=flat)](https://npmjs.org/package/handlebars-helper-repeat) [![Linux Build Status](https://img.shields.io/travis/helpers/handlebars-helper-repeat.svg?style=flat&label=Travis)](https://travis-ci.org/helpers/handlebars-helper-repeat)
> Handlebars block helper for repeating whatever is inside the block `n` number of times.
> Handlebars block helper for repeating whatever is inside the block _n_ times.
If you find a bug or have a feature request, [please create an issue](https://github.com/helpers/handlebars-helper-repeat/issues).
## Install
## Install with [npm](npmjs.org)
Install with [npm](https://www.npmjs.com/):
```bash
npm i handlebars-helper-repeat --save
```sh
$ npm install --save handlebars-helper-repeat
```
If you find a bug or have a feature request, [please create an issue](https://github.com/helpers/handlebars-helper-repeat/issues).
## Usage

@@ -41,5 +43,5 @@

- `count` the total number of blocks being generated
- `index` the index of the current block
- `start` the start number to use instead of zero. Basically `index + start`
* `count` the total number of blocks being generated
* `index` the index of the current block
* `start` the start number to use instead of zero. Basically `index + start`

@@ -85,29 +87,45 @@ Example:

## Related projects
* [template-helpers](https://github.com/jonschlinkert/template-helpers): Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or any engine that supports helper functions.
* [handlebars-helpers](https://github.com/assemble/handlebars-helpers): 120+ Handlebars helpers in ~20 categories, for Assemble, YUI, Ghost or any Handlebars project. Includes helpers like {{i18}}, {{markdown}}, {{relative}}, {{extend}}, {{moment}}, and so on.
## About
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/helpers/handlebars-helper-repeat/issues)
### Related projects
## Running tests
Install dev dependencies.
* [handlebars-helpers](https://www.npmjs.com/package/handlebars-helpers): More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate… [more](https://github.com/assemble/handlebars-helpers) | [homepage](https://github.com/assemble/handlebars-helpers "More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate, Verb, Ghost, gulp-handlebars, grunt-handlebars, consolidate, or any node.js/Handlebars project.")
* [template-helpers](https://www.npmjs.com/package/template-helpers): Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or… [more](https://github.com/jonschlinkert/template-helpers) | [homepage](https://github.com/jonschlinkert/template-helpers "Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or any engine that supports helper functions.")
```bash
npm i -d && npm test
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Building docs
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
```sh
$ npm install -g verb verb-generate-readme && verb
```
## Authors
### Running tests
Install dev dependencies:
```sh
$ npm install -d && npm test
```
### Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
### License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](LICENSE).
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 15, 2015._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.3.0, on January 08, 2017._

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc