Node.js 玉石中的新线保存
每当我呈现JADE模板时,我都会在一行中获得所有HTML。这使得在查看源代码模式下很难读取。如何让JADE创建正确缩进的HTML 这是我的模板:Node.js 玉石中的新线保存,node.js,pug,Node.js,Pug,每当我呈现JADE模板时,我都会在一行中获得所有HTML。这使得在查看源代码模式下很难读取。如何让JADE创建正确缩进的HTML 这是我的模板: #application p#docs a(href='/docs/index.html') Documentation p#user-input input#msg(name='msg', size='50') input#submit(name='submit', type='submit', value='Sen
#application
p#docs
a(href='/docs/index.html') Documentation
p#user-input
input#msg(name='msg', size='50')
input#submit(name='submit', type='submit', value='Send a Message')
ul#messages
在Jade的编译选项中,将
pretty
设置为true
这可以通过多种方式完成,具体取决于编译方式
- 从命令行传递
或-P
标志-pretty
- 从express 3.x:
app.locals.pretty=true代码>
app.set('view options',{pretty:true});
,请参阅迁移指南:)
然后您可以执行以下操作
#test. // <-- notice the dot
Lorem Ipsum is simply dummy text of
the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy
text ever since the 1500s ,
when an unknown printer took a galley of type and scrambled
#测试。//我使用Express中的Jade,所以我在“.set('view options',{pretty:true})”之后使用了“app.set('view engine','Jade');”,但是,我仍然在一行中获取所有HTML。我在问题中添加了我的Jade模板。您使用的是哪个版本的express?在express 3中,我认为您必须将其从app.localsapp.locals.pretty=true
更改。检查这个啊,这些令人沮丧的版本。。。我2天前才开始使用NodeJS,我已经要“迁移”。。。无论如何谢谢你!
<div id="test">
Lorem Ipsum is simply dummy text of
the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy
text ever since the 1500s ,
when an unknown printer took a galley of type and scrambled
</div>