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.19.4 to 1.0.0

67

index.js
'use strict';
var utils = require('./utils');
var Helpers = require('helper-cache');
var AsyncHelpers = require('async-helpers');
var extend = require('extend-shallow');
var isObject = require('isobject');
var merge = require('mixin-deep');

@@ -24,4 +29,4 @@ /**

this.cache = engines || {};
this.AsyncHelpers = this.options.AsyncHelpers || utils.AsyncHelpers;
this.Helpers = this.options.Helpers || utils.Helpers;
this.AsyncHelpers = this.options.AsyncHelpers || AsyncHelpers;
this.Helpers = this.options.Helpers || Helpers;
}

@@ -55,4 +60,7 @@

decorate(engine);
// add custom inspect method
inspect(engine);
if (this.options.customInspect !== false) {
inspect(engine);
}

@@ -150,3 +158,3 @@ // set the engine on the cache

if (!utils.isObject(fn) && typeof fn !== 'function') {
if (!isObject(fn) && typeof fn !== 'function') {
throw new TypeError('expected an object or function');

@@ -157,3 +165,3 @@ }

engine.render = fn.render || fn;
engine.options = utils.extend({}, options);
engine.options = extend({}, options);

@@ -164,8 +172,12 @@ if (typeof engine.render !== 'function') {

for (var key in fn) {
var keys = Object.keys(fn);
var len = keys.length;
var idx = -1;
while (++idx < len) {
var key = keys[idx];
if (key === 'options') {
engine.options = utils.merge({}, engine.options, fn[key]);
engine.options = extend({}, engine.options, fn[key]);
continue;
}
if (key === '__express' && !fn.hasOwnProperty('renderFile')) {
if (key === '__express') {
engine.renderFile = fn[key];

@@ -219,9 +231,9 @@ }

if (typeof options !== 'undefined' && !utils.isObject(options)) {
if (typeof options !== 'undefined' && !isObject(options)) {
throw new TypeError('expected options to be an object or undefined');
}
options = utils.extend({}, options);
options = extend({}, options);
var helpers = mergeHelpers(engine, options);
var compiled = compile ? compile.call(engine, str, helpers) : null;
var compiled = compile ? compile(str, helpers) : null;

@@ -250,10 +262,10 @@ return function(locals, cb) {

} else {
data = utils.merge({}, locals, helpers);
data = merge({}, locals, helpers);
}
if (typeof cb !== 'function') {
return renderSync.call(engine, str, data);
return renderSync(str, data);
}
render.call(engine, str, data, function(err, str) {
render(str, data, function(err, str) {
if (err) {

@@ -294,3 +306,4 @@ cb(err);

if (typeof str === 'function') {
str(locals, cb);
var fn = str;
fn(locals, cb);
return;

@@ -308,6 +321,6 @@ }

// compile the template to create a function
var fn = this.compile(str, locals);
var render = this.compile(str, locals);
// call the function to render templates
fn(locals, function(err, content) {
render(locals, function(err, content) {
if (err) {

@@ -346,6 +359,5 @@ cb(err);

var context = utils.extend({}, locals);
context.helpers = utils.merge({}, this.helpers, context.helpers);
var render = this.compile(str, context);
return render(context);
var context = extend({}, locals);
context.helpers = merge({}, this.helpers, context.helpers);
return this.compile(str, context)(context);
};

@@ -379,9 +391,8 @@ }

var opts = utils.extend({}, options);
var helpers = utils.merge({}, engine.helpers, opts.helpers);
for (var key in helpers) {
if (helpers.hasOwnProperty(key)) {
engine.asyncHelpers.set(key, helpers[key]);
}
var opts = extend({}, options);
var helpers = merge({}, engine.helpers.cache, opts.helpers);
var keys = Object.keys(helpers);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
engine.asyncHelpers.set(key, helpers[key]);
}

@@ -388,0 +399,0 @@

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

@@ -11,3 +11,4 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"contributors": [
"Brian Woodward (https://github.com/doowb)"
"Brian Woodward <brian.woodward@gmail.com> (https://twitter.com/doowb)",
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)"
],

@@ -31,21 +32,20 @@ "repository": "jonschlinkert/engine-cache",

"dependencies": {
"async-helpers": "^0.3.9",
"async-helpers": "^0.3.14",
"extend-shallow": "^2.0.1",
"helper-cache": "^0.7.2",
"helper-cache": "^1.0.0",
"isobject": "^3.0.0",
"lazy-cache": "^2.0.2",
"mixin-deep": "^1.1.3"
"mixin-deep": "^1.2.0"
},
"devDependencies": {
"consolidate": "^0.14.5",
"engine-base": "^0.1.2",
"engine-handlebars": "^0.8.0",
"engine-base": "^0.1.3",
"engine-handlebars": "^0.8.2",
"engines": "^0.4.0",
"gulp": "^3.9.1",
"gulp-format-md": "^0.1.11",
"gulp-eslint": "^3.0.1",
"gulp-format-md": "^0.1.12",
"gulp-istanbul": "^1.1.1",
"gulp-jshint": "^2.0.4",
"gulp-mocha": "^3.0.1",
"gulp-mocha": "^3.0.0",
"gulp-unused": "^0.2.1",
"handlebars": "^4.0.6",
"jshint-stylish": "^2.2.1",
"lodash": "^4.17.4",

@@ -112,7 +112,5 @@ "mocha": "^3.2.0",

"reflinks": [
"helper-cache",
"verb",
"verb-readme-generator"
]
}
}

@@ -13,2 +13,8 @@ # engine-cache [![NPM version](https://img.shields.io/npm/v/engine-cache.svg?style=flat)](https://www.npmjs.com/package/engine-cache) [![NPM monthly downloads](https://img.shields.io/npm/dm/engine-cache.svg?style=flat)](https://npmjs.org/package/engine-cache) [![NPM total downloads](https://img.shields.io/npm/dt/engine-cache.svg?style=flat)](https://npmjs.org/package/engine-cache) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/engine-cache.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/engine-cache) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/engine-cache.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/engine-cache)

Install with [yarn](https://yarnpkg.com):
```sh
$ yarn add engine-cache
```
## Usage

@@ -22,3 +28,3 @@

### [Engines](index.js#L21)
### [Engines](index.js#L26)

@@ -36,3 +42,3 @@ **Params**

### [.setEngine](index.js#L43)
### [.setEngine](index.js#L48)

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

### [.setEngines](index.js#L74)
### [.setEngines](index.js#L82)

@@ -71,3 +77,3 @@ Add an object of engines onto `engines.cache`.

### [.getEngine](index.js#L101)
### [.getEngine](index.js#L109)

@@ -92,3 +98,3 @@ Return the engine stored by `ext`. If no `ext` is passed, undefined is returned.

### [.helpers](index.js#L132)
### [.helpers](index.js#L140)

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

**v0.19.0** ensure the string is only rendered once by passing the compiled function to the `render` method
**v0.18.0** the `.load` method was renamed to `.setHelpers`

@@ -145,3 +149,3 @@

| 113 | [jonschlinkert](https://github.com/jonschlinkert) |
| 48 | [doowb](https://github.com/doowb) |
| 51 | [doowb](https://github.com/doowb) |

@@ -160,3 +164,3 @@ ### Building docs

Install dev dependencies:
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

@@ -177,6 +181,6 @@ ```sh

Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](LICENSE).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 21, 2017._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 20, 2017._
'use strict';
var utils = require('lazy-cache')(require);
var fn = require;
require = utils;
var isObject = require('isobject');
var utils = module.exports;

@@ -11,9 +10,2 @@ /**

require('async-helpers', 'AsyncHelpers');
require('extend-shallow', 'extend');
require('helper-cache', 'Helpers')
require('isobject', 'isObject');
require('mixin-deep', 'merge');
require = fn;
utils.isString = function(val) {

@@ -45,3 +37,3 @@ return val && typeof val === 'string';

if (typeof val === 'function') return true;
if (!utils.isObject(val)) return false;
if (!isObject(val)) return false;
return val.hasOwnProperty('render')

@@ -48,0 +40,0 @@ || val.hasOwnProperty('renderSync')

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