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.10.6 to 0.11.0

49

index.js
'use strict';
var debug = require('debug')('engine-cache');
var AsyncHelpers = require('async-helpers');
var Helpers = require('helper-cache');
var merge = require('mixin-deep');
var forOwn = require('for-own');
var async = require('async');
var _ = require('lodash');

@@ -37,3 +35,2 @@ /**

Engines.prototype.init = function(engines) {
debug('init %j', arguments);
this.cache = engines || {};

@@ -58,5 +55,3 @@ };

Engines.prototype.setEngine = function (ext, fn, options) {
debug('[set]: %s, %j, %j', ext, fn, options);
var engine = {};
if (arguments.length === 3) {

@@ -70,16 +65,23 @@ if (options && (typeof options === 'function' ||

options = opts;
opts = null;
}
}
if (typeof fn === 'function') {
engine.render = fn.render || fn;
if (fn.renderSync) {
engine.renderSync = fn.renderSync;
}
} else if (typeof fn === 'object') {
engine = fn || this.noop;
engine.renderFile = fn.renderFile || fn.__express;
var type = typeof fn;
if (type !== 'object' && type !== 'function') {
throw new TypeError('engine-cache expects engines to be an object or function.');
}
engine.compile = engine.compile || fn.compile;
engine.options = merge({}, engine.options || {}, fn.options || {}, options || {});
engine.render = fn.render || fn;
if (fn.renderFile) {
engine.renderFile = fn.renderFile;
}
if (fn.__express) {
engine.renderFile = fn.__express;
}
for (var key in fn) {
engine[key] = fn[key];
}
engine.options = _.merge({}, engine.options, fn.options, options);
engine.helpers = new Helpers(options);

@@ -99,7 +101,6 @@ engine.asyncHelpers = new AsyncHelpers(options);

this.decorate(engine);
if (ext[0] !== '.') {
if (ext.charAt(0) !== '.') {
ext = '.' + ext;
}
debug('[set] %s: %j', ext, engine);
this.cache[ext] = engine;

@@ -154,4 +155,2 @@ return this;

Engines.prototype.decorate = function(engine) {
debug('[decorate]: %j', engine);
var renderSync = engine.renderSync;

@@ -189,3 +188,3 @@ var render = engine.render;

var opts = merge({}, {async: true}, options);
var opts = _.extend({async: true}, options);
var ctx = mergeHelpers.call(this, opts);

@@ -212,3 +211,3 @@ var self = this;

opts = opts || {};
opts.helpers = merge({}, this.helpers, opts.helpers);
opts.helpers = _.merge({}, this.helpers, opts.helpers);
return renderSync(str, opts);

@@ -261,4 +260,2 @@ };

Engines.prototype.load = function(engines) {
debug('[load]: %j', engines);
for (var key in engines) {

@@ -351,7 +348,7 @@ if (engines.hasOwnProperty(key)) {

function mergeHelpers (options) {
this.asyncHelpers.helpers = merge({},
this.asyncHelpers.helpers = _.merge({},
filterHelpers(this.helpers, true),
filterHelpers(options.helpers, true));
options.helpers = merge({},
options.helpers = _.merge({},
filterHelpers(this.helpers),

@@ -358,0 +355,0 @@ filterHelpers(options.helpers),

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

@@ -46,6 +46,3 @@ "author": {

"async-helpers": "^0.1.2",
"debug": "^2.1.3",
"for-own": "^0.1.3",
"helper-cache": "^0.6.0",
"mixin-deep": "^1.0.1"
"helper-cache": "^0.6.0"
},

@@ -97,2 +94,2 @@ "devDependencies": {

]
}
}

@@ -18,3 +18,3 @@ # engine-cache [![NPM version](https://badge.fury.io/js/engine-cache.svg)](http://badge.fury.io/js/engine-cache)

## API
### [Engines](./index.js#L26)
### [Engines](index.js#L26)

@@ -28,3 +28,3 @@ * `engines` **{Object}**: Optionally pass an object of engines to initialize with.

### [.setEngine](./index.js#L56)
### [.setEngine](index.js#L55)

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

### [.getEngine](./index.js#L122)
### [.getEngine](index.js#L125)

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

### [.load](./index.js#L234)
### [.load](index.js#L254)

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

### [.helpers](./index.js#L268)
### [.helpers](index.js#L286)

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

### [.clear](./index.js#L286)
### [.clear](index.js#L304)

@@ -133,5 +133,5 @@ 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 April 01, 2015._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 21, 2015._
[helper-cache]: https://github.com/jonschlinkert/helper-cache
<!-- 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