[英]Jade using Javascript variables
I have the following example code 我有以下示例代码
extends layout
block append content
- var user = {name:'hello word'}
include includes/header
div.container
p
#{user.name}
#blogs
- each blog in blogs
div.blog
strong
div.title
a(href="/blog/"+blog._id)!= blog.title
small
div.created_at= blog.created_at
div.body= blog.body.substring(0,100) + ' ... '
a(href="/blog/"+blog._id)!= 'Read More'
include includes/footer
This renders HTML output that contains 这将呈现包含以下内容的HTML输出:
<p>
<hello world><hello>
</p>
Can anyone explain what is going on here according to the Jade tutorial this should render correctly ... 任何人都可以根据应该正确呈现的Jade教程解释这里发生了什么...
If you were expecting hello world
as text: 如果您希望以文字形式
hello world
:
<p>
hello world
</p>
Then, Jade needs just a bit more instruction since the default meaning of a line-break and indent is a child element. 然后,Jade只需要多一点指令,因为换行和缩进的默认含义是子元素。
Options include: 选项包括:
Keeping the element and text on the same line (" Inline in a Tag "): 保持元素和文本在同一行(“ 在标签中内联 ”):
p #{user.name}
Also, if that's the only text within the <p>
: 另外,如果那是
<p>
的唯一文本:
p= user.name
Using a |
使用
|
to specify the line as text (" Piped Text "): 将行指定为文本(“ Piped Text ”):
p | #{user.name}
Trailing the element with a .
在元素后面加上
.
so all content under it is text (" Block in a Tag "): 因此其下的所有内容均为文本(“ 代码中的阻止 ”):
p. #{user.name}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.