header.mustache
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>blog</title>
</head>
<body>
<nav>
<ul>
<li>
<a href="/">상품목록</a>
</li>
<li>
<a href="/store/save-form">상품등록</a>
</li>
<li>
<a href="/log">구매목록</a>
</li>
</ul>
</nav>
<hr>
log → list.mustache
{{>layout/header}}
<section>
<table border="1">
<tr>
<th>주문번호</th>
<th>상품명(조인)</th>
<th>구매개수</th>
<th>총가격</th>
<th>구매자이름</th>
</tr>
{{#models}}
<tr>
<td>{{id}}</td>
<td>{{name}}</td>
<td>{{qty}}</td>
<td>{{totalPrice}}</td>
<td>{{buyer}}</td>
</tr>
{{/models}}
</table>
</section>
</body>
</html>
detail.mustache
{{> layout/header}}
<section>
<form action="/store/{{model.id}}/update-form" method="get">
<button type="submit">수정</button>
</form>
<form action="/store/{{model.id}}/delete" method="post">
<button type="submit">삭제</button>
</form>
<div>
번호 : {{model.id}} <br>
상품명 : {{model.name}} <br>
상품가격 : {{model.price}}원 <br>
상품재고 : {{model.stock}}개 <br>
</div>
<hr>
<form action="/log/save" method="post">
<input type="hidden" value="{{model.id}}" name="storeId">
<input type="text" placeholder="당신은 누구인가요?" name="buyer">
<input type="text" placeholder="Enter 개수" name="qty">
<button type="submit">구매</button>
</form>
</section>
</body>
</html>
store → list.mustache
{{>layout/header}}
<section>
<table border="1">
<tr>
<th>번호</th>
<th>상품명</th>
<th></th>
</tr>
{{#models}}
<tr>
<td>{{id}}</td>
<td>{{name}}</td>
<td><a href="/store/{{id}}">상세보기</a></td>
</tr>
{{/models}}
</table>
</section>
</body>
</html>
save-form.mustache
{{> layout/header}}
<section>
<form action="/store/save" method="post">
<input type="text" placeholder="상품명" name="name" value="바나나"><br>
<input type="text" placeholder="수량" name="stock" value="50"><br>
<input type="text" placeholder="가격" name="price" value="3000"><br>
<button type="submit">상품등록</button>
</form>
</section>
</body>
</html>
update-form.mustache
{{> layout/header}}
<section>
<form action="/store/{{model.id}}/update" method="post">
<input type="text" value="{{model.name}}" name="name"><br>
<input type="text" value="{{model.stock}}" name="stock"><br>
<input type="text" value="{{model.price}}" name="price"><br>
<button type="submit">상품수정</button>
</form>
</section>
</body>
</html>
Share article