Huge News!Announcing our $40M Series B led by Abstract Ventures.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.12.2 to 0.13.0

65

index.js

@@ -6,3 +6,2 @@ 'use strict';

var Helpers = require('helper-cache');
var async = require('async');

@@ -26,16 +25,6 @@ /**

function Engines(engines) {
this.init(engines);
this.cache = engines || {};
}
/**
* Initialize default configuration.
*
* @api private
*/
Engines.prototype.init = function(engines) {
this.cache = engines || {};
};
/**
* Register the given view engine callback `fn` as `ext`.

@@ -93,5 +82,7 @@ *

if (engine.render) {
if (!engine.name && engine.render) {
engine.name = engine.render.name;
} else {
}
if (!engine.name && engine.renderSync) {
engine.name = engine.renderSync.name;

@@ -131,3 +122,2 @@ }

}
var engine = this.cache[ext];

@@ -137,3 +127,2 @@ if (!engine) {

}
return engine;

@@ -173,2 +162,3 @@ };

}
var orig;

@@ -180,5 +170,6 @@ if (typeof cb !== 'function') {

if (typeof str === 'function') {
return this.resolve(str(options), cb);
return engine.asyncHelpers.resolveIds(str(options), cb);
} else if (typeof str === 'string') {
orig = str;
str = this.compile(str, options);

@@ -192,7 +183,10 @@

var ctx = mergeHelpers.call(this, opts);
var self = this;
return render.call(this, str, ctx, function (err, content) {
if (err) return cb(err);
return self.resolve(content, cb);
if (content instanceof Error) {
return cb(content);
}
return engine.asyncHelpers.resolveIds(content, cb);
});

@@ -216,31 +210,2 @@ };

};
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;
// `stash` contains the objects created when rendering the template
var stashed = self.asyncHelpers.stash;
async.eachSeries(Object.keys(stashed), function (key, next) {
// check to see if the async ID is in the rendered string
if (str.indexOf(key) === -1) {
return next(null);
}
self.asyncHelpers.resolve(key, function (err, value) {
if (err) return next(err);
// replace the async ID with the resolved value
str = str.split(key).join(value);
next(null);
});
}, function (err) {
if (err) return cb(err);
cb(null, str);
});
};
};

@@ -282,4 +247,4 @@

* var helpers = engines.helpers('hbs');
* helpers.addHelper('foo', function() {});
* helpers.getHelper('foo');
* helpers.addHelper('bar', function() {});
* helpers.getHelper('bar');
* helpers.getHelper();

@@ -286,0 +251,0 @@ * ```

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

@@ -41,4 +41,3 @@ "author": {

"dependencies": {
"async": "^1.1.0",
"async-helpers": "^0.2.2",
"async-helpers": "^0.3.0",
"extend-shallow": "^1.1.4",

@@ -50,3 +49,3 @@ "helper-cache": "^0.7.1"

"engine-handlebars": "^0.6.1",
"engine-lodash": "^0.6.3",
"engine-lodash": "^0.7.1",
"engines": "^0.4.0",

@@ -53,0 +52,0 @@ "handlebars": "^3.0.2",

@@ -19,3 +19,3 @@ # engine-cache [![NPM version](https://badge.fury.io/js/engine-cache.svg)](http://badge.fury.io/js/engine-cache) [![Build Status](https://travis-ci.org/jonschlinkert/engine-cache.svg)](https://travis-ci.org/jonschlinkert/engine-cache)

### [Engines](index.js#L24)
### [Engines](index.js#L23)

@@ -33,3 +33,3 @@ **Params**

### [.setEngine](index.js#L53)
### [.setEngine](index.js#L42)

@@ -52,3 +52,3 @@ Register the given view engine callback `fn` as `ext`.

### [.getEngine](index.js#L123)
### [.getEngine](index.js#L114)

@@ -72,3 +72,3 @@ Return the engine stored by `ext`. If no `ext` is passed, the entire cache is returned.

### [.load](index.js#L253)
### [.load](index.js#L218)

@@ -88,3 +88,3 @@ Load an object of engines onto the `cache`. Mostly useful for testing, but exposed as a public method.

### [.helpers](index.js#L285)
### [.helpers](index.js#L250)

@@ -106,8 +106,8 @@ Get and set helpers for the given `ext` (engine). If no `ext` is passed, the entire helper cache is returned.

var helpers = engines.helpers('hbs');
helpers.addHelper('foo', function() {});
helpers.getHelper('foo');
helpers.addHelper('bar', function() {});
helpers.getHelper('bar');
helpers.getHelper();
```
### [.clear](index.js#L303)
### [.clear](index.js#L268)

@@ -162,4 +162,4 @@ Remove `ext` engine from the cache, or if no value is specified the entire cache is reset.

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 01, 2015._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 18, 2015._
<!-- deps: swig lodash mocha engine-lodash handlebars -->
<!-- deps: swig lodash mocha engine-lodash handlebars -->
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