node.js - How to output pretty html in Express? -


i've noticed while using express node.js, outputs html code without newline characters or tabs. it's not pretty, although technically more efficient downloading.

how print nice formatted html?

in main app.js or in it's place:

express 4.x

if (app.get('env') === 'development') {   app.locals.pretty = true; } 

express 3.x

app.configure('development', function(){   app.use(express.errorhandler());   app.locals.pretty = true; }); 

express 2.x

app.configure('development', function(){   app.use(express.errorhandler());   app.set('view options', { pretty: true }); }); 

i put pretty print in development because you'll want more efficiency 'ugly' in production. make sure set environment variable node_env=production when you're deploying in production. can done sh script use in 'script' field of package.json , executed start.

express 3 changed because:

the "view options" setting no longer necessary, app.locals local variables merged res.render()'s, [app.locals.pretty = true same passing res.render(view, { pretty: true }).


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -