gpt4 book ai didi

node.js - 在 Jade 中保留换行符

转载 作者:搜寻专家 更新时间:2023-10-31 23:10:11 24 4
gpt4 key购买 nike

每当我呈现 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 });,参见迁移指南:https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x )

然后你可以进行以下操作

#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

会产生

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

关于node.js - 在 Jade 中保留换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13743941/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com