Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Sep 24, 2015
1 parent 2af77b8 commit 1882375
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 68 deletions.
1 change: 0 additions & 1 deletion CONTRIBUTING.md

This file was deleted.

34 changes: 22 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,37 @@ var utils = require('./lib/utils');

function Cache(options) {
this.options = options || {};
this.helpers = {};
this.handlebars = this.options.handlebars;
delete this.options.handlebars;

if (!this.handlebars) {
throw new Error('handlebars-helpers expects an instance of handlebars.');
}

this.helpers = this.handlebars.helpers;
this.groups = {};

if (this.options.helpers) {
this.visit('register', this.options.helpers);
delete this.options.helpers;
}

if (this.options.groups) {
this.visit('group', this.options.groups);
delete this.options.groups;
}
}

Cache.prototype.register = function(name, fn) {
this.helpers[name] = fn;
this.handlebars.registerHelper(name, fn);
return this;
};

Cache.prototype.group = function(key, value) {
this.groups[key] = new Cache({helpers: value});
this.groups[key] = new Cache({
handlebars: this.handlebars,
helpers: value
});
return this;
};

Expand All @@ -39,16 +52,13 @@ Cache.prototype.visit = function(method, value) {
return this;
};

var cache = new Cache({groups: groups});




console.log(cache)


module.exports = function (handlebars) {
return new Cache({
handlebars: handlebars,
groups: groups
});
};

// module.exports = cache;
// module.exports.Cache = Cache;
// module.exports.cache = cache;
// module.exports.utils = utils;
10 changes: 0 additions & 10 deletions lib/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,6 @@ exports.compare = function(left, operator, right, options) {
}
};

/**
* @source: Dan Harper <http://github.com/danharper>
*
* @param {[type]} context
* @param {[type]} options
* @return {[type]}
*
* @example: {{if_eq this compare=that}}
*/

exports.if_eq = function(context, options) {
if (context === options.hash.compare) {
return options.fn(this);
Expand Down
7 changes: 0 additions & 7 deletions lib/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ exports.default = function(value, defaultValue) {
return value != null ? value : defaultValue;
};

/**
* http://handlebarsjs.com/block_helpers.html
* @param {[type]} options
* @return {[type]}
* @api public
*/

exports.noop = function(options) {
return options.fn(this);
};
Expand Down
59 changes: 30 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
"description": "More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, YUI, Ghost or any node.js/Handlebars project.",
"version": "0.6.0",
"homepage": "https://github.com/assemble/handlebars-helpers",
"repository": "assemble/handlebars-helpers",
"bugs": {
"url": "https://github.com/assemble/handlebars-helpers/issues"
},
"author": {
"name": "Assemble",
"url": "https://github.com/assemble/assemble/handlebars-helpers"
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"maintainers": [
{
Expand All @@ -17,17 +21,7 @@
"url": "https://github.com/doowb"
}
],
"repository": {
"type": "git",
"url": "git://github.com/assemble/handlebars-helpers.git"
},
"bugs": {
"url": "https://github.com/assemble/handlebars-helpers/issues"
},
"license": {
"type": "MIT",
"url": "https://github.com/assemble/handlebars-helpers/blob/master/LICENSE"
},
"license": "MIT",
"files": [
"index.js",
"lib/"
Expand All @@ -41,39 +35,46 @@
},
"dependencies": {
"any": "^1.0.0",
"arr-filter": "^1.1.0",
"arr-filter": "^1.1.1",
"arr-flatten": "^1.0.1",
"collection-visit": "^0.2.0",
"export-files": "^2.1.0",
"extend-shallow": "^1.1.2",
"handlebars": "^3.0.0",
"helper-cache": "^0.7.2",
"helper-concat": "^0.2.0",
"helper-date": "^0.2.1",
"extend-shallow": "^2.0.1",
"handlebars": "^4.0.2",
"helper-concat": "^0.3.0",
"helper-date": "^0.2.2",
"helper-glob": "^0.1.0",
"helper-markdown": "^0.1.1",
"helper-markdown": "^0.1.2",
"helper-md": "^0.1.0",
"html-tag": "^0.2.1",
"index-of": "^0.1.0",
"is-number": "^1.1.2",
"js-yaml": "^3.2.7",
"kind-of": "^1.1.0",
"lodash": "^3.5.0",
"logging-helpers": "^0.3.0",
"make-iterator": "^0.1.1",
"index-of": "^0.2.0",
"is-number": "^2.0.2",
"js-yaml": "^3.4.2",
"kind-of": "^2.0.1",
"lodash": "^3.10.1",
"logging-helpers": "^0.4.0",
"make-iterator": "^0.2.0",
"object.pluck": "^0.1.2",
"randomatic": "^1.1.0",
"relative": "^2.0.0",
"relative": "^3.0.1",
"to-gfm-code-block": "^0.1.1"
},
"devDependencies": {
"chalk": "^1.1.1",
"code-context": "^0.5.3",
"engine": "^0.1.8",
"extract-comments": "^0.7.3",
"for-own": "^0.1.3",
"gulp": "^3.9.0",
"gulp-istanbul": "^0.6.0",
"gulp-jshint": "^1.9.2",
"gulp-mocha": "^2.0.0",
"jshint-stylish": "^1.0.1",
"parse-comments": "^0.4.1",
"should": "^5.2.0",
"verb": "^0.5.0"
"through2": "^2.0.0",
"verb": "^0.5.0",
"vinyl": "^0.5.3"
},
"keywords": [
"assemble",
Expand Down
20 changes: 11 additions & 9 deletions test/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

var should = require('should');
var Handlebars = require('handlebars');
var helpers = require('..');
var helpers = require('..')(Handlebars);

Handlebars.registerHelper(helpers('array'));
console.log(helpers);

var context = {arr: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']};
// Handlebars.registerHelper(helpers('array'));

describe('isArray', function() {
it('should return true if the value is an array.', function() {
Handlebars.compile('{{isArray "foo"}}')().should.eql('false');
Handlebars.compile('{{isArray foo}}')({foo: ['foo']}).should.equal('true');
});
});
// var context = {arr: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']};

// describe('isArray', function() {
// it('should return true if the value is an array.', function() {
// Handlebars.compile('{{isArray "foo"}}')().should.eql('false');
// Handlebars.compile('{{isArray foo}}')({foo: ['foo']}).should.equal('true');
// });
// });

// describe('arrayify', function() {
// it('should coerce a value to an array.', function() {
Expand Down

0 comments on commit 1882375

Please sign in to comment.