Skip to content

Commit

Permalink
creating common header file for all ejs files
Browse files Browse the repository at this point in the history
  • Loading branch information
codingXpert committed Jul 2, 2022
1 parent 2af19d4 commit 230ca36
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions common/header.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<nav>
<h3>
Header File
</h3>
</nav>
4 changes: 4 additions & 0 deletions index2.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ app.get('/profile' , (req , res) => {
res.render('profile' , {user});
});

app.get('/login' , (req , res) => {
res.render('login')
})


app.listen(port , (err) => {
if(!err){
Expand Down
3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
<title>Index page</title>
</head>
<body>
<!-- WE can't use <%- ('../common/header')%> in html files -->
<h1>Index page</h1>
<style>
h1{
color: orange;
}
</style>
</body>
</html>
</html>
13 changes: 13 additions & 0 deletions views/login.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Page</title>
</head>
<body>
<%- include('../common/header') %>
<h1>This is Login Page</h1>
</body>
</html>
1 change: 1 addition & 0 deletions views/profile.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</head>
<body>

<%- include('../common/header') %>
<h1>Profile Page</h1>
<h3>Welcome <%= user.name %></h3>
<h3>Email:<%= user.email %></h3>
Expand Down

0 comments on commit 230ca36

Please sign in to comment.