Includes
INCLUDES - it is used to create sub-templates
syntax- <%- include("includes/head.ejs")
here includes- Folder name
head.ejs -file name
insta.ejs
<%- include("includes/head.ejs"); %>
<body>
<h1>Welcome to the page of @<%=data.name%></h1>
<button>Follow</button>
<button>Message</button>
<p>Followers: <%= data.followers %> Following: <%=data.following %></p>
<!-- LOOP FOR POSTS -->
<% for(let post of data.posts){ %>
<img src="<%= post.image%>" />
<p>Likes: <%=post.likes%> comments:<%= post.comments %></p>
<% } %>
<%- include("includes/footer.ejs");%>
</body>
<script src="/app.js"></script>
</html>
head.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Instagram page</title>
<link rel="stylesheet" href="/style.css">
</head>
footer.ejs

Comments
Post a Comment