Skip to content

Commit bf64aa7

Browse files
useernameivan.naimark
authored and
ivan.naimark
committed
Merge tag 'v0.13.1'
0.13.1 Conflicts: lib/consolidate.js
2 parents bcac438 + ab0cbe5 commit bf64aa7

File tree

6 files changed

+584
-408
lines changed

6 files changed

+584
-408
lines changed

History.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
0.13.0 / 2015-05-26
2+
===================
3+
4+
* fixes react template error
5+
* adds promises when a callback function is not passed to `render`
6+
* documentation updates
7+
18
0.11.0 / 2015-02-07
29
==================
310

Readme.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ cons[name]('views/page.html', { user: 'tobi' }, function(err, html){
7979
});
8080
```
8181

82+
### Promises
83+
84+
Additionally, all templates optionally return a promise if no callback function is provided. The promise represents the eventual result of the template function which will either resolve to a string, compiled from the template, or be rejected. Promises expose a `then` method which registers callbacks to receive the promise’s eventual value and a `catch` method which the reason why the promise could not be fulfilled. Promises allow more synchronous-like code structure and solve issues like race conditions.
85+
86+
```js
87+
var cons = require('consolidate');
88+
89+
cons.swig('views/page.html', { user: 'tobi' })
90+
.then(function (html) {
91+
console.log(html);
92+
})
93+
.catch(function (err) {
94+
throw err;
95+
});
96+
```
97+
8298
## Caching
8399

84100
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.
@@ -137,7 +153,7 @@ var cons = require('consolidate'),
137153

138154
// add nunjucks to requires so filters can be
139155
// added and the same instance will be used inside the render method
140-
cons.requires.nunjucks = nunjucks;
156+
cons.requires.nunjucks = nunjucks.configure();
141157

142158
cons.requires.nunjucks.addFilter('foo', function () {
143159
return 'bar';

0 commit comments

Comments
 (0)