engine-cache
Advanced tools
Comparing version 0.2.6 to 0.3.0
19
index.js
@@ -65,3 +65,3 @@ 'use strict'; | ||
Engines.prototype.register = function (ext, options, fn) { | ||
Engines.prototype.register = function (ext, fn, options) { | ||
var args = [].slice.call(arguments).filter(Boolean); | ||
@@ -72,13 +72,12 @@ | ||
if (args.length === 3 && typeof options === 'function') { | ||
var opts = fn; | ||
fn = options; | ||
options = opts; | ||
if (args.length === 3) { | ||
if (options && (typeof options === 'function' || | ||
options.hasOwnProperty('render') || | ||
options.hasOwnProperty('renderFile'))) { | ||
var opts = fn; | ||
fn = options; | ||
options = opts; | ||
} | ||
} | ||
if (args.length === 2) { | ||
fn = options; | ||
options = {}; | ||
} | ||
if (typeof fn === 'function') { | ||
@@ -85,0 +84,0 @@ engine = fn; |
{ | ||
"name": "engine-cache", | ||
"description": "express.js inspired template-engine manager.", | ||
"version": "0.2.6", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/jonschlinkert/engine-cache", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -89,3 +89,41 @@ /*! | ||
}); | ||
it('should allow options to be passed as the last argument.', function() { | ||
engines | ||
.register('a', {render: function () {}}, {foo: 'bar'}) | ||
.register('b', {render: function () {}}, {foo: 'bar'}) | ||
.register('c', {render: function () {}}, {foo: 'bar'}) | ||
.register('d', {render: function () {}}, {foo: 'bar'}); | ||
var a = engines.get('.a'); | ||
assert.equal(typeof a, 'object'); | ||
assert.equal(typeof a.render, 'function'); | ||
assert.equal(typeof a.options.foo, 'string'); | ||
engines.engines.should.have.property('.a'); | ||
engines.engines.should.have.property('.b'); | ||
engines.engines.should.have.property('.c'); | ||
engines.engines.should.have.property('.d'); | ||
Object.keys(engines.engines).length.should.equal(4); | ||
}); | ||
it('should allow options to be passed as the second argument.', function() { | ||
engines | ||
.register('a', {foo: 'bar'}, {render: function () {}}) | ||
.register('b', {foo: 'bar'}, {render: function () {}}) | ||
.register('c', {foo: 'bar'}, {render: function () {}}) | ||
.register('d', {foo: 'bar'}, {render: function () {}}); | ||
var a = engines.get('.a'); | ||
assert.equal(typeof a, 'object'); | ||
assert.equal(typeof a.render, 'function'); | ||
assert.equal(typeof a.options.foo, 'string'); | ||
engines.engines.should.have.property('.a'); | ||
engines.engines.should.have.property('.b'); | ||
engines.engines.should.have.property('.c'); | ||
engines.engines.should.have.property('.d'); | ||
Object.keys(engines.engines).length.should.equal(4); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25187
590