New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

engine-cache

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

engine-cache - npm Package Compare versions

Comparing version 0.13.0 to 0.14.0

77

index.js

@@ -142,5 +142,3 @@ 'use strict';

var render = engine.render;
var compile = engine.compile || function (str) {
return str;
};
var compile = engine.compile;

@@ -150,3 +148,33 @@ engine.compile = function wrappedCompile(str, opts) {

opts = opts || {};
return compile(str, mergeHelpers.call(this, opts));
var fn = compile && compile(str, mergeHelpers.call(this, opts));
return function (locals, cb) {
var content = str;
if (typeof fn === 'function') {
// already compiled
try {
content = fn(locals);
} catch (err) {
if (typeof cb === 'function') return cb(err);
throw err;
}
if (typeof cb !== 'function') {
return content;
} else {
return engine.asyncHelpers.resolveIds(content, cb);
}
} else {
var ctx = extend({}, mergeHelpers.call(this, opts), locals);
if (typeof cb !== 'function') {
return renderSync(content, ctx);
} else {
return render(content, ctx, function (err, content) {
if (err) return cb(err);
if (content instanceof Error) {
return cb(content);
}
return engine.asyncHelpers.resolveIds(content, cb);
});
}
}
}.bind(this);
};

@@ -159,3 +187,2 @@

}
var orig;

@@ -167,39 +194,21 @@ if (typeof cb !== 'function') {

if (typeof str === 'function') {
return engine.asyncHelpers.resolveIds(str(options), cb);
return str(options, cb);
} else if (typeof str === 'string') {
orig = str;
str = this.compile(str, options);
} else {
return cb(new TypeError('engine-cache `render` expects a string or function.'));
var opts = extend({async: true}, options);
str = this.compile(str, opts);
return str(opts, cb);
}
var opts = extend({async: true}, options);
var ctx = mergeHelpers.call(this, opts);
return render.call(this, str, ctx, function (err, content) {
if (err) return cb(err);
if (content instanceof Error) {
return cb(content);
}
return engine.asyncHelpers.resolveIds(content, cb);
});
return cb(new TypeError('engine-cache `render` expects a string or function.'));
};
engine.renderSync = function wrappedRenderSync(str, opts) {
engine.renderSync = function wrappedRenderSync(str, options) {
if (typeof str === 'function') {
return str(opts);
return str(options);
} else if (typeof str === 'string') {
var opts = extend({}, options);
opts.helpers = extend({}, this.helpers, opts.helpers);
str = this.compile(str, opts);
} else {
throw new TypeError('engine-cache `renderSync` expects a string or function.');
return str(opts);
}
opts = opts || {};
opts.helpers = extend({}, this.helpers, opts.helpers);
return renderSync(str, opts);
throw new TypeError('engine-cache `renderSync` expects a string or function.');
};

@@ -206,0 +215,0 @@ };

{
"name": "engine-cache",
"description": "express.js inspired template-engine manager.",
"version": "0.13.0",
"version": "0.14.0",
"homepage": "https://github.com/jonschlinkert/engine-cache",

@@ -51,2 +51,3 @@ "author": {

"handlebars": "^3.0.2",
"lodash": "^3.10.0",
"mocha": "^2.2.4",

@@ -53,0 +54,0 @@ "should": "^6.0.1",

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