Jac*_*ack 4 javascript node.js express pug
是否可以将HTML元素传递到jade文件中,例如我希望以下内容用文本填充p元素,以及包含嵌套在p元素内的一些包含文本的代码元素.
包含字符串的JSON
var news = {
one : {
title : "Using JSON",
body : "Using JSON is a great way of passing information into the jade template files."+
"It can be looped over using jades each syntax <code>test</code>"
},
two : {
title : "",
body : ""
}
}
Run Code Online (Sandbox Code Playgroud)
路由HTTP请求
// Routes
app.get(navigation.home.uri, function(req, res){ //Home
res.render(navigation.home.url, {
title: navigation.home.title,
navigation: navigation,
news: news
});
});
Run Code Online (Sandbox Code Playgroud)
Jade文件片段,每个新闻项都有一个循环
section#news
- each item in news
article(class="news")
header
h2 #{item.title}
p #{item.body}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4285 次 |
| 最近记录: |