Turn on line breaks in Jade source?
Is there a way to turn on line breaks? It would be useful when debugging.
I know this topic ( Node.js JADE linebreaks in source?开发者_运维百科 ) says no due to performance, but on your local machine when developing, it should't be a problem.
After a bit of searching I found the solution. Add this to your Express configuration, and it will make Jade tidy up the output:
Express 3.x CoffeeScript
app.configure "development", ->
app.use express.errorHandler()
app.locals.pretty = true
Express 3.x Javascript
app.configure('development', function(){
app.use(express.errorHandler());
app.locals.pretty = true;
});
Express 2.x CoffeeScript
app.configure "development", ->
app.use express.errorHandler()
app.set "view options",
pretty: true
Express 2.x Javascript
app.configure('development', function(){
app.use(express.errorHandler());
app.set('view options', { pretty: true });
});
You can run it through a beautifier for debugging
here's one written for node https://github.com/maxogden/commonjs-html-prettyprinter
精彩评论