on-rendered
v1.0.4
Published
emit events when express start render and finish render.
Downloads
1
Readme
on-rendered
Emit events when express start render and finish render.
Installation
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
$ npm install on-rendered -S
API
var onRender = require('on-rendered')
app.use(onRender());
This will add the event render
to fire when template are rendered. And a
event beforeRender
add to template is ready to render.
Examples
var bodyParser = require('body-parser')
var cookieParser = require('cookie-parser')
var express = require('express')
var onRender = require('on-rendered')
// example of using this top-level; note the use of haltOnTimedout
// after every middleware; it will stop the request flow on a timeout
var app = express()
app.use(onRender())
app.use(bodyParser())
app.use(cookieParser())
app.get('/path', function(req, res) {
res.on('render', function() {
console.log('after render and before send')
});
res.on('beforeRender', function() {
console.log('before render');
});
res.render('foo.html');
})
app.listen(3000)