2011-06-28 42 views
5

我想知道,爲什麼我在我的源代碼中看不到任何換行符,如果我解析我的模板。它看起來像這樣:Node.js源代碼中的JADE換行符?

!!! 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 

現在我的源代碼是這樣的:

<!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> 

將是蠻好看的源代碼中換行符調試或不?任何人都有一個思想,我可以如何管理這個? Thx的信息!

回答

15

有時候,你想看到漂亮的HTML輸出。要取消醜化你的玉輸出,通過pretty選項編譯器在app.js:

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

隨着快遞3.x版,記住,你需要這個來代替: app.locals.pretty = true; – chilts

+0

如果從shell調用jade,您也可以使用--pretty開關 – Pete

7

由於默認情況下,Jade不會將任何換行符編譯到您的html源代碼中。

這只是發送不必要的字節到客戶端放慢下載​​速度和增加帶寬消耗。

類似的問題:Express and pretty HTML

+0

THX,我想我理解現在:) – ayk