Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'swig-defaults'
Browse files Browse the repository at this point in the history
  • Loading branch information
spcoder committed Aug 9, 2014
2 parents 84c691a + 9ad5bc2 commit 17dd0ac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Readme.md
Expand Up @@ -74,11 +74,11 @@ cons[name]('views/page.html', { user: 'tobi' }, function(err, html){

## Caching

To enable caching simply pass `{ cache: true }`. Engines _may_ use this option to cache things reading the file contents, compiled `Function`s etc. Engines which do _not_ support this may simply ignore it. All engines that consolidate.js implements I/O for will cache the file contents, ideal for production environments.
To enable or disable caching simply pass `{ cache: true/false }`. Engines _may_ use this option to cache things reading the file contents, compiled `Function`s etc. Engines which do _not_ support this may simply ignore it. All engines that consolidate.js implements I/O for will cache the file contents, ideal for production environments.

```js
var cons = require('consolidate');
cons.swig('views/page.html', { user: 'tobi' }, function(err, html){
cons.swig('views/page.html', { cache: false, user: 'tobi' }, function(err, html){
if (err) throw err;
console.log(html);
});
Expand Down
2 changes: 2 additions & 0 deletions lib/consolidate.js
Expand Up @@ -250,8 +250,10 @@ exports.swig = fromStringRenderer('swig');

exports.swig.render = function(str, options, fn){
var engine = requires.swig || (requires.swig = require('swig'));

try {
if(options.cache === true) options.cache = 'memory';
engine.setDefaults({ cache: options.cache });
var tmpl = cache(options) || cache(options, engine.compile(str, options));
fn(null, tmpl(options));
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -14,7 +14,7 @@
"jade": "0.26.0",
"ejs": "0.7.1",
"eco": "1.1.0-rc-3",
"swig": "0.12.0",
"swig": "1.4.1",
"jazz": "0.0.18",
"jqtpl": "1.1.0",
"liquor": "0.0.4",
Expand Down

0 comments on commit 17dd0ac

Please sign in to comment.