为什么 Jade 不能在 Express.js 中正确格式化其输出
我在 Express.js 中使用 Jade,我注意到 html 输出全部在一行中。在 Jade 网站上 ( http://scalate.fusesource.org/documentation/jade-syntax .html )它说格式化输出是标准的,选项是 ScamlOptions.nl 和 ScamlOptions.indent,但我无法在任何地方找到这些选项来查看它们是否是设置不正确。有谁知道我在哪里可以找到这些选项,或者是否有其他方法可以强制进行干净的格式化?
谢谢!
该线程没有帮助: 如何在 Express 中输出漂亮的 html?
I am using Jade in Express.js and I noticed that the html output is all in one line. On the Jade website ( http://scalate.fusesource.org/documentation/jade-syntax.html ) it says that formatted output is standard and that the options are ScamlOptions.nl and ScamlOptions.indent, but I can't find those options anywhere to see if they are set incorrectly. Does anyone know where I can find those options or is there another way to force clean formatting?
Thanks!
This thread didn't help:
How to output pretty html in Express?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Express 3 中,(至少)此视图选项的 api 已更改。
我设置了 app.locals.pretty ,它似乎工作得很好。在
app.configure()
中设置视图引擎后,我立即在app.js
(或server.js
)中调用它In Express 3, the api has changed for (at least) this view option.
I set
app.locals.pretty
and it seems to be working just fine. I call it within myapp.js
(orserver.js
) right after I set the view engine inapp.configure()
另外,Jade 的设计初衷并不是为了创建人类可读的输出。所有缩进和换行都只是浪费空间,对于任何浏览器处理 HTML 来说并不重要。但您可以尝试:
app.set('view options', { Pretty: true });
Also, Jade is not designed to create human-readable output. All the indention and new lines are just wasting space and are not important for any browser to process you HTML. But you could try:
app.set('view options', { pretty: true });