Skip to content

Commit

Permalink
Merge pull request #324 from A-312/patch-2
Browse files Browse the repository at this point in the history
Improve documentation about Express version
  • Loading branch information
doowb authored Jul 11, 2019
2 parents 45fbf85 + 091da11 commit d4a27d8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
## Installation

$ npm install consolidate

## Supported Express versions

- [Espress 4.x](https://expressjs.com/fr/4x/api.html)
- [Express 3.x](https://expressjs.com/fr/3x/api.html)

## Supported template engines

Expand Down Expand Up @@ -57,7 +62,7 @@ __NOTE__: you must still install the engines you wish to use, add them to your p

## API

All templates supported by this library may be rendered using the signature `(path[, locals], callback)` as shown below, which happens to be the signature that Express 3.x supports so any of these engines may be used within Express.
All templates supported by this library may be rendered using the signature `(path[, locals], callback)` as shown below, which happens to be the signature that Express supports so any of these engines may be used within Express.

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

Expand Down Expand Up @@ -111,9 +116,9 @@ cons.swig('views/page.html', { user: 'tobi' })

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.
When using consolidate directly: `cons.swig('views/page.html', { user: 'tobi', cache:true }, callback);`
Using Express 3 or higher: `app.locals.cache = true` or set NODE_ENV to 'production' and Express will do this for you.
Using supported Express versions: `app.locals.cache = true` or set NODE_ENV to 'production' and Express will do this for you.

## Express 3.x example
## Express example

```js
var express = require('express')
Expand Down

0 comments on commit d4a27d8

Please sign in to comment.