diff --git a/readme.md b/readme.md index 34a59b5..2b0154b 100644 --- a/readme.md +++ b/readme.md @@ -9,9 +9,12 @@ ## 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 @@ -19,12 +22,19 @@ 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 : "", + resave: false, + saveUninitialized: true + })); + + // initialise the flash middleware app.use(flash()); ``` @@ -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}} +
+

{{messages.info}}

+
+{{/if}} ``` ## Requires - * cookieParser - * session + * session - http-session middleware - install it using `npm install --save express-session` -## License +## License (The MIT License) @@ -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. \ No newline at end of file +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.