Node.js JADE linebreaks in source?

一笑奈何 提交于 2020-01-13 10:23:06

问题


I wonder, why i don't see any linebreaks in my sourcecode if i parse my jade template. It looks like this:

!!! 5
html
head
    title= title
    link(rel='stylesheet', href='/stylesheets/css.css')
    link(rel='stylesheet', href='/stylesheets/blitzer/jquery-ui-1.8.10.custom.css')
    link(rel='stylesheet', href='/stylesheets/table_jui.css')

    script(type="text/javascript", src="/javascripts/jquery.min.js")
    script(type="text/javascript", src="/javascripts/jquery-ui.min.js")
    script(type="text/javascript", src="/javascripts/jquery.jwNotify.js")
    script(type="text/javascript", src="/javascripts/jquery.dataTables.min.js")
    script(type="text/javascript", src="/javascripts/js.js")

body!= body

Now my sourcecode looks like this:

<!DOCTYPE html><html><head><title>Express v2</title><link rel="stylesheet" href="/stylesheets/css.css"><link rel="stylesheet" href="/stylesheets/blitzer/jquery-ui-1.8.10.custom.css"><link rel="stylesheet" href="/stylesheets/table_jui.css"><script type="text/javascript" src="/javascripts/jquery.min.js"></script><script type="text/javascript" src="/javascripts/jquery-ui.min.js"></script><script type="text/javascript" src="/javascripts/jquery.jwNotify.js"></script><script type="text/javascript" src="/javascripts/jquery.dataTables.min.js"></script><script type="text/javascript" src="/javascripts/js.js"></script></head><body></body></html>

Would be fine to see line breaks in sourcecode to debug or not? Anyone has an ideo, how i can manage this? Thx for info!


回答1:


Sometimes, you want to see pretty html output. To un-uglify your Jade output, pass the pretty option to the compiler in your app.js:

app.set('view options', { pretty: true });



回答2:


Because Jade doesn't compile any line breaks into your html source by default.

It's just sending unneccesary bytes to the client slowing download speed and increasing bandwidth consumption.

Similar Question: Express and pretty HTML



来源:https://stackoverflow.com/questions/6504624/node-js-jade-linebreaks-in-source

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!