[英]Line Breaks Inside Jade Templates
I was looking around for a solution to include a line break inside a title. 我一直在寻找解决方案,以在标题中包含换行符。 The normal fixes for this are to include an actual line break inside your code...
正常的解决方法是在代码中包含实际的换行符。
<div title="Ron
Swanson"></div>
Or to use 
或使用

in place of your new line, like so... 代替您的新行,就像这样...
<div title="Ron 
Swanson"></div>
These solutions work fine, however since I'm using Jade as a templating engine, I can't properly include a line break inside my code... 这些解决方案工作正常,但是由于我将Jade用作模板引擎,因此我无法在代码中适当包含换行符...
.title(title="Ron
Swanson")
--OR-- - 要么 -
.title(title="Ron\
Swanson")
Without the \\
it throws a syntax error, and with it doesn't actually insert a line break. 如果没有
\\
它将引发语法错误,并且实际上不会插入换行符。 Also `.title(title="Ron Swanson") prints out those characters literally. 同样,`.title(title =“ Ron Swanson”)会从字面上打印出这些字符。
What is the correct way of including line breaks in your Jade templates? 在Jade模板中包括换行符的正确方法是什么?
I found out that I can use \\n
to represent a new line (just like a JavaScript string). 我发现可以使用
\\n
代表换行符(就像JavaScript字符串一样)。 Doing something like this will work... 做这样的事情会起作用...
.title(title="Ron\nSwanson")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.