Skip to content

Instantly share code, notes, and snippets.

@valotas
Last active December 31, 2015 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valotas/7956887 to your computer and use it in GitHub Desktop.
Save valotas/7956887 to your computer and use it in GitHub Desktop.
A way to override express' app.render function
app.use((req: express.Request, resp: express.Response, next?: Function) => {
var render = resp.render;
resp.render = (view: string, options?: any, fn?: any) => {
if ('function' == typeof options) {
fn = options;
options = {};
}
render.call(resp, view, options, (err, html) => {
if (html) {
html = typo(html).typogrify();
}
if (fn) {
fn(err, html);
} else {
if (err) next(err);
resp.send(html);
}
});
};
next();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment