Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.