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 : ""
}
}
HTTP リクエストのルーティング
// Routes
app.get(navigation.home.uri, function(req, res){ //Home
res.render(navigation.home.url, {
title: navigation.home.title,
navigation: navigation,
news: news
});
});
各ニュース項目のループを含む Jade ファイルのスニペット
section#news
- each item in news
article(class="news")
header
h2 #{item.title}
p #{item.body}