const fakeUser = {
username: "Nicolas",
loggedIn: true,
};
export const trending = (req, res) =>
res.render("home", { pageTitle: "Home", fakeUser });
=====================
body
header
if fakeUser.loggedIn
small Hello #{fakeUser.username}
nav
ul
if fakeUser.loggedIn
li
a(href="/logout") Log out
else
li
a(href="/login") Login
export const trending = (req, res) => {
const videos = [
{
title: "Hello",
},
{
title: "Video #2",
},
{
title: "WhatUp",
},
];
return res.render("home", { pageTitle: "Home", videos });
};
====================
ul
each video in videos
li=video.title
else
li Sorry nothing found.
: 데이터를 받을 수 있는 partial
// home.pug
block content
h2 Welcome here you will see the trending videos
each video in videos
div
h4 video.title
ul
li #{video.rating}/5
li #{video.comments} comments.
li Posted #{video.createdAt}.
li #{video.views} views.
mixin video(info)
div
h4=info.title
ul
li #{info.rating}/5
li #{info.comments} comments.
li Posted #{info.createdAt}.
li #{info.views} views.
=======================================
include mixins/video
each potato in videos
+video(potato)
ch6.8~ mongo (0) | 2022.08.17 |
---|---|
ch6. mongoDB & Mongoose (0) | 2022.08.16 |
ch5. Templates (0) | 2022.08.14 |
ch4. Routers (0) | 2022.08.11 |
ch3. express intro (0) | 2022.08.09 |
댓글 영역