Comparing version 0.0.7 to 0.2.0
16
index.js
@@ -12,3 +12,4 @@ module.exports = function(req, res, next) { | ||
req.oneFlash = function(type, message) { | ||
if(!type){ | ||
if (!message) { | ||
message = type; | ||
type = 'info'; | ||
@@ -24,8 +25,11 @@ } | ||
res.render = function(view, options, fn) { | ||
if (typeof(options) === 'object') { | ||
if (req.session.flash.length > 0 && res.locals.flash.length === 0) { | ||
options.flash = req.session.flash; | ||
req.session.flash = []; | ||
} | ||
if (!options) { | ||
options = {}; | ||
} | ||
if (req.session.flash.length > 0 && res.locals.flash.length === 0) { | ||
options.flash = req.session.flash; | ||
req.session.flash = []; | ||
} | ||
_render.call(this, view, options, fn); | ||
@@ -32,0 +36,0 @@ } |
{ | ||
"name": "one-flash", | ||
"version": "0.0.7", | ||
"version": "0.2.0", | ||
"description": "A flash implementation for Express that goes away after the first navigation.", | ||
@@ -5,0 +5,0 @@ "main": "server.js", |
@@ -32,3 +32,3 @@ # one-flash | ||
router.get('/flashrender', function(req, res) { | ||
req.oneFlash('hello render'); | ||
req.oneFlash('hello render'); // notice how type is not required. It will default to 'info'. | ||
res.render('index', { | ||
@@ -45,3 +45,3 @@ title: 'Index - TEST' | ||
{% for message in flash %} | ||
<div class="alert alert-{{ message.type if message.type else "info" }} alert-dismissible" role="alert"> | ||
<div class="alert alert-{{ message.type }} alert-dismissible" role="alert"> | ||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | ||
@@ -48,0 +48,0 @@ {{ message.message }} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15640
12
28