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 %> &nbsp;&nbsp; Following: <%=data.following %></p>

    <!-- LOOP FOR POSTS  -->
    <% for(let post of data.posts){ %>
    <img src="<%= post.image%>" />
    <p>Likes: <%=post.likes%>&nbsp;&nbsp; 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

<div style="background-color: bisque;">
    <h3>Contact Info</h3>
    <p>E-Mail: abc@gmail.com <br>
    Mobile:xxxxx</p>
</div>

Comments

Popular posts from this blog

DATABASE RELATIONSHIPS

ROUTING (GET /) home route

Query Strings