[英]Jade using Javascript variables
我有以下示例代碼
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
這將呈現包含以下內容的HTML輸出:
<p>
<hello world><hello>
</p>
任何人都可以根據應該正確呈現的Jade教程解釋這里發生了什么...
如果您希望以文字形式hello world
:
<p>
hello world
</p>
然后,Jade只需要多一點指令,因為換行和縮進的默認含義是子元素。
選項包括:
保持元素和文本在同一行(“ 在標簽中內聯 ”):
p #{user.name}
另外,如果那是<p>
的唯一文本:
p= user.name
使用|
將行指定為文本(“ Piped Text ”):
p | #{user.name}
在元素后面加上.
因此其下的所有內容均為文本(“ 代碼中的阻止 ”):
p. #{user.name}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.