在Jade中保留换行符
每当我呈现一个JADE模板时,我会在一行中获得所有的HTML。 这使得在视图源模式下难以阅读。 我如何告诉JADE创build正确缩进的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
真实。
根据你编译的方式,可以用多种方式完成
- 从命令行传递
-P
或--pretty
标志。 - 从快车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>