Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 玉石中的新线保存_Node.js_Pug - Fatal编程技术网

Node.js 玉石中的新线保存

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

每当我呈现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='Send a Message')

  ul#messages

在Jade的编译选项中,将
pretty
设置为true

这可以通过多种方式完成,具体取决于编译方式

  • 从命令行传递
    -P
    -pretty
    标志
  • 从express 3.x:
    app.locals.pretty=true
(express 2.x使用了不同的语法:
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.locals
app.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>