Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a HandlebarsJS example #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,32 @@

## Installation

Works with Express 3.x.x
Install it using:

npm install git://github.com/RGBboy/express-flash.git
```
npm install --save express-flash
npm install --save express-session
```


## Usage

Set it up the same way you would `connect-flash`:

``` javascript
var flash = require('express-flash'),
express = require('express'),
app = express();

app.use(express.cookieParser('keyboard cat'));
app.use(express.session({ cookie: { maxAge: 60000 }}));
const flash = require('express-flash');
const session = require('express-session');
const express = require('express');
const app = express();

// initialise session middleware - flash-express depends on it
app.use(session({
secret : "<add a secret string here>",
resave: false,
saveUninitialized: true
}));

// initialise the flash middleware
app.use(flash());
```

Expand All @@ -43,20 +53,21 @@ Use `req.flash()` in your middleware
});
```

Access the messages in your views via `locals.messages` (.jade in this case):
Access messages in Handlebars views use `locals.messages`:

``` jade
- if (messages.info)
.message.info
span= messages.info
```handlebars
{{#if messages.info}}
<div class="entry">
<h1> {{messages.info}}</h1>
</div>
{{/if}}
```

## Requires

* cookieParser
* session
* session - http-session middleware - install it using `npm install --save express-session`

## License
## License

(The MIT License)

Expand All @@ -79,4 +90,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.