pug
Pug와 반복
수색…
소개
간단한 JSON 객체를 반복하고 많은 타이핑을 저장하는 법
비고
Node.js와 Pug가 설치되어 있어야합니다.
각 반복
간단한 데이터 저장소 로 app.js 만들기 :
app.get("/bookstore", function (req, res, next) {
// Your route data
var bookStore = [
{
title: "Templating with Pug",
author: "Winston Smith",
pages: 143,
year: 2017
},
{
title: "Node.js will help",
author: "Guy Fake",
pages: 879,
year: 2015
}
];
res.render("index", {
bookStore: bookStore
});
});
index.pug 파일과 각 루프를 사용하여 데이터 저장소를 반복합니다.
each book in bookStore
ul
li= book.title
li= book.author
li= book.pages
li= book.year
결과는 다음과 같습니다.
<ul>
<li>Templating with Pug</li>
<li>Winston Smith</li>
<li>143</li>
<li>2017</li>
</ul>
<ul>
<li>Node.js will help</li>
<li>Guy Fake</li>
<li>879</li>
<li>2015</li>
</ul>
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow