Socket
Socket
Sign inDemoInstall

consolidate

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

consolidate - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

7

History.md
0.4.0 / 2012-07-30
==================
* add doT support [sannis]
* add mustache support [ForbesLindesay]
* add walrus support [kagd]
0.3.1 / 2012-06-28

@@ -3,0 +10,0 @@ ==================

113

lib/consolidate.js

@@ -58,4 +58,4 @@

// cached
if (options.cache && str) return fn(null, str);
// cached (only if cached is a string and not a compiled template function)
if (options.cache && str && typeof str === 'string') return fn(null, str);

@@ -96,14 +96,23 @@ // read

read(path, options, function(err, str) {
if (err) return fn(err);
try {
options.filename = path;
if (!options.cache) engine.cache = {};
engine.renderSource(str, options, function(err, tmpl) {
fn(err, tmpl);
});
} catch (err) {
fn(err);
}
});
var tmpl = cache[path];
// try cache (only if cached is a compiled template function and not a string)
if (options.cache && tmpl && 'function' == typeof tmpl) {
tmpl(options, fn);
} else {
read(path, options, function(err, str) {
if (err) return fn(err);
try {
options.filename = path;
tmpl = engine.compileFn(str);
if (options.cache) cache[path] = tmpl;
else engine.cache = {};
tmpl(options, fn);
} catch (err) {
fn(err);
}
});
}
};

@@ -268,3 +277,3 @@

exports['hogan'] = function(path, options, fn){
exports.hogan = function(path, options, fn){
var engine = requires.hogan || (requires.hogan = require('hogan.js'));

@@ -334,2 +343,74 @@ read(path, options, function(err, str){

}
};
};
/**
* Walrus support.
*/
exports.walrus = function (path, options, fn) {
var engine = requires.walrus || (requires.walrus = require('walrus'));
var tmpl = cache[path];
// try cache (only if cached is a compiled template function and not a string)
if (options.cache && tmpl && 'function' == typeof tmpl) {
tmpl(options, fn);
} else {
read(path, options, function(err, str){
if (err) return fn(err);
try {
var tmpl = engine.parse(str);
fn(null, tmpl.compile(options));
} catch (err) {
fn(err);
}
});
}
};
/**
* Mustache support.
*/
exports.mustache = function(path, options, fn) {
var engine = requires.mustache || (requires.mustache = require('mustache'));
read(path, options, function(err, str){
if (err) return fn(err);
try {
options.filename = path;
fn(null, engine.to_html(str, options));
} catch (err) {
fn(err);
}
});
};
/**
* doT support.
*/
exports.dot = function(path, options, fn) {
var engine = requires.dot || (requires.dot = require('dot'));
var tmpl = cache[path];
// try cache (only if cached is a compiled template function and not a string)
if (options.cache && tmpl && 'function' == typeof tmpl) {
try {
var html = tmpl(options);
fn(null, html);
} catch (err) {
fn(err);
}
} else {
read(path, options, function(err, str) {
if (err) return fn(err);
try {
var tmpl = engine.template(str);
cache[path] = tmpl;
fn(null, tmpl(options));
} catch (err) {
fn(err);
}
});
}
};

16

package.json
{
"name": "consolidate",
"version": "0.3.1",
"version": "0.4.0",
"description": "Template engine consolidation library",

@@ -17,7 +17,7 @@ "keywords": [

"eco": "1.1.0-rc-3",
"swig": "0.11.2",
"swig": "0.12.0",
"jazz": "0.0.18",
"jqtpl": "1.1.0",
"liquor": "0.0.4",
"hamljs": "0.6.0",
"hamljs": "0.6.1",
"whiskers": "0.2.2",

@@ -30,5 +30,11 @@ "haml-coffee": "0.6.3",

"underscore": "1.3.3",
"qejs": "0.0.1"
"qejs": "0.0.1",
"walrus": "0.9.0",
"mustache": "0.4.0",
"dot": "0.2.6"
},
"main": "index"
"main": "index",
"scripts": {
"test": "mocha"
}
}

@@ -22,5 +22,7 @@ # Consolidate.js

- [liquor](https://github.com/chjj/liquor)
- [mustache](https://github.com/janl/mustache.js)
- [QEJS](https://github.com/jepso/QEJS)
- [swig](https://github.com/paularmstrong/swig) [(website)](http://paularmstrong.github.com/swig/)
- [underscore](https://github.com/documentcloud/underscore) [(website)](http://documentcloud.github.com/underscore/)
- [walrus](https://github.com/jeremyruppel/walrus) [(website)](http://documentup.com/jeremyruppel/walrus/)
- [whiskers](https://github.com/gsf/whiskers.js/tree/)

@@ -34,2 +36,4 @@

__NOTE__: All this example code uses cons.swig for the swig template engine. Replace swig with whatever templating you are using. For exmaple, use cons.hogan for hogan.js, cons.jade for jade, etc. `console.log(cons)` for the full list of identifiers.
```js

@@ -36,0 +40,0 @@ var cons = require('consolidate');

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