mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 12:19:51 +01:00
Fixed flash example. Closes #392
This commit is contained in:
parent
498115d5d9
commit
ae1c20fad9
|
|
@ -26,6 +26,12 @@ app.set('view engine', 'ejs');
|
||||||
|
|
||||||
app.dynamicHelpers({
|
app.dynamicHelpers({
|
||||||
messages: function(req, res){
|
messages: function(req, res){
|
||||||
|
// In the case of flash messages
|
||||||
|
// we return a function, allowing
|
||||||
|
// flash messages to only be flushed
|
||||||
|
// when called, otherwise every request
|
||||||
|
// will flush flash messages regardless.
|
||||||
|
return function(){
|
||||||
// Grab the flash messages
|
// Grab the flash messages
|
||||||
var messages = req.flash();
|
var messages = req.flash();
|
||||||
// We will render the "messages.ejs" partial
|
// We will render the "messages.ejs" partial
|
||||||
|
|
@ -44,6 +50,7 @@ app.dynamicHelpers({
|
||||||
dynamicHelpers: false
|
dynamicHelpers: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/', function(req, res){
|
app.get('/', function(req, res){
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
<h1>Flash Message Example</h1>
|
<h1>Flash Message Example</h1>
|
||||||
<%- messages %>
|
<%- messages() %>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user