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.14.0 to 0.14.1

70

index.js
'use strict';
var extend = require('extend-shallow');
var AsyncHelpers = require('async-helpers');
var Helpers = require('helper-cache');
var lazy = require('lazy-cache')(require);
lazy('extend-shallow', 'extend');
lazy('async-helpers', 'AsyncHelpers');
lazy('helper-cache', 'Helpers');

@@ -72,5 +73,5 @@ /**

engine.options = extend({}, engine.options, fn.options, options);
engine.helpers = new Helpers(options);
engine.asyncHelpers = new AsyncHelpers(options);
engine.options = lazy.extend({}, engine.options, fn.options, options);
engine.helpers = new lazy.Helpers(options);
engine.asyncHelpers = new lazy.AsyncHelpers(options);

@@ -145,2 +146,19 @@ if (typeof engine.render !== 'function' && typeof engine.renderSync !== 'function') {

/**
* Wrapped compile function for all engines loaded onto engine-cache.
* If possible, compiles the string with the original engine's compile function.
* Returns a render function that will either use the original engine's compiled function
* or the `render/renderSync` methods and will resolve async helper ids.
*
* ```js
* var fn = engine.compile('<%= upper(foo) %>', {imports: {'upper': upper}});
* console.log(fn({foo: 'bar'})));
* //=> BAR
* ```
*
* @param {String} `str` Original string to compile.
* @param {Object} `opts` Options/settings to pass to engine's compile function.
* @return {Function} Returns render function to call that takes `locals` and optional `callback` function.
*/
engine.compile = function wrappedCompile(str, opts) {

@@ -166,3 +184,3 @@ if (typeof str === 'function') return str;

} else {
var ctx = extend({}, mergeHelpers.call(this, opts), locals);
var ctx = lazy.extend({}, mergeHelpers.call(this, opts), locals);
if (typeof cb !== 'function') {

@@ -183,2 +201,18 @@ return renderSync(content, ctx);

/**
* Wrapped render function for all engines loaded onto engine-cache.
* Compiles and renders strings with given context.
*
* ```js
* engine.render('<%= foo %>', {foo: 'bar'}, function (err, content) {
* console.log(content);
* });
* //=> bar
* ```
*
* @param {String|Function} `str` Original string to compile or function to use to render.
* @param {Object} `options` Options/locals to pass to compiled function for rendering.
* @param {Function} `cb` Callback function that returns `err, content`.
*/
engine.render = function wrappedRender(str, options, cb) {

@@ -197,3 +231,3 @@ if (typeof options === 'function') {

} else if (typeof str === 'string') {
var opts = extend({async: true}, options);
var opts = lazy.extend({async: true}, options);
str = this.compile(str, opts);

@@ -205,2 +239,16 @@ return str(opts, cb);

/**
* Wrapped renderSync function for all engines loaded onto engine-cache.
* Compiles and renders strings with given context.
*
* ```js
* console.log(engine.renderSync('<%= foo %>', {foo: 'bar'}));
* //=> bar
* ```
*
* @param {String|Function} `str` Original string to compile or function to use to render.
* @param {Object} `options` Options/locals to pass to compiled function for rendering.
* @return {String} Returns rendered content.
*/
engine.renderSync = function wrappedRenderSync(str, options) {

@@ -210,4 +258,4 @@ if (typeof str === 'function') {

} else if (typeof str === 'string') {
var opts = extend({}, options);
opts.helpers = extend({}, this.helpers, opts.helpers);
var opts = lazy.extend({}, options);
opts.helpers = lazy.extend({}, this.helpers, opts.helpers);
str = this.compile(str, opts);

@@ -301,5 +349,5 @@ return str(opts);

function mergeHelpers (opts) {
extend(this.asyncHelpers.helpers, this.helpers, opts.helpers);
lazy.extend(this.asyncHelpers.helpers, this.helpers, opts.helpers);
opts.helpers = this.asyncHelpers.get({wrap: opts.async});
return opts;
}

18

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

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

],
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/engine-cache.git"
},
"repository": "jonschlinkert/engine-cache",
"bugs": {

@@ -42,5 +39,6 @@ "url": "https://github.com/jonschlinkert/engine-cache/issues"

"dependencies": {
"async-helpers": "^0.3.0",
"extend-shallow": "^1.1.4",
"helper-cache": "^0.7.1"
"async-helpers": "^0.3.2",
"extend-shallow": "^2.0.1",
"helper-cache": "^0.7.1",
"lazy-cache": "^0.2.3"
},

@@ -53,6 +51,6 @@ "devDependencies": {

"handlebars": "^3.0.2",
"lodash": "^3.10.0",
"mocha": "^2.2.4",
"should": "^6.0.1",
"swig": "^1.4.2"
"swig": "^1.4.2",
"time-require": "jonschlinkert/time-require"
},

@@ -59,0 +57,0 @@ "keywords": [

@@ -69,3 +69,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)

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

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

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

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

### [.clear](index.js#L268)
### [.clear](index.js#L324)

@@ -159,4 +159,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 18, 2015._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 09, 2015._
<!-- 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