engine-cache
Advanced tools
Comparing version 0.10.5 to 0.10.6
33
index.js
@@ -170,12 +170,21 @@ 'use strict'; | ||
if (typeof str !== 'function') { | ||
str = this.compile(str, options); | ||
if (typeof cb !== 'function') { | ||
throw new TypeError('engine-cache `render` expects a callback function.'); | ||
} | ||
if (typeof str === 'function') { | ||
return this.resolve(str(options), cb); | ||
} else if (typeof str === 'string') { | ||
str = this.compile(str, options); | ||
} else { | ||
return cb(new TypeError('engine-cache `render` expects a string or function.')); | ||
} | ||
var opts = merge({}, {async: true}, options); | ||
var ctx = mergeHelpers.call(this, opts); | ||
var self = this; | ||
return render.call(this, str, mergeHelpers.call(this, opts), function (err, content) { | ||
return render.call(this, str, ctx, function (err, content) { | ||
if (err) return cb(err); | ||
@@ -187,7 +196,10 @@ return self.resolve(content, cb); | ||
engine.renderSync = function wrappedRenderSync(str, opts) { | ||
if (typeof str !== 'function') { | ||
str = this.compile(str, opts); | ||
} | ||
if (typeof str === 'function') { | ||
return str(opts); | ||
} else if (typeof str === 'string') { | ||
str = this.compile(str, opts); | ||
} else { | ||
throw new TypeError('engine-cache `renderSync` expects a string or function.'); | ||
} | ||
@@ -201,2 +213,9 @@ | ||
engine.resolve = function resolveHelpers(str, cb) { | ||
if (typeof cb !== 'function') { | ||
throw new TypeError('engine-cache `resolve` expects a callback function.'); | ||
} | ||
if (typeof str !== 'string') { | ||
return cb(new TypeError('engine-cache `resolve` expects a string.')); | ||
} | ||
var self = this; | ||
@@ -291,3 +310,3 @@ // `stash` contains the objects created when rendering the template | ||
if (ext) { | ||
if (ext[0] !== '.') ext = '.' + ext; | ||
if (ext && ext.charAt(0) !== '.') ext = '.' + ext; | ||
delete this.cache[ext]; | ||
@@ -294,0 +313,0 @@ } else { |
{ | ||
"name": "engine-cache", | ||
"description": "express.js inspired template-engine manager.", | ||
"version": "0.10.5", | ||
"version": "0.10.6", | ||
"homepage": "https://github.com/jonschlinkert/engine-cache", | ||
@@ -6,0 +6,0 @@ "author": { |
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
15757
304