EJS
Embedded Java Script Templates
used for creatng a template that can be used for multiple paages(to display)
just like for every instagram user there is a different profile page . it is not that every page is coded seperately. We use these templates
create a directory EJS within the same directory install express and ejs packages
create another in the name of VIEWS in this create a file home.ejs
index.js
const express=require("express");
const app=express();
const port=8080;
app.set("view engine","ejs");
app.get("/",(req,res)=>{
res.render("home.ejs");
});
app.listen(port,()=>{
console.log(`server is listening on port ${port}`);
});
home.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Demo views</title>
</head>
<body>
<h1>Demo for EJS</h1>
<p>
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eius ad harum,
suscipit mollitia laudantium quia non error distinctio, repellendus
consequuntur quis. Quaerat assumenda, aliquid iusto veritatis rerum
repellat animi voluptate?
</p>
<button>click me</button>
</body>
</html>

Comments
Post a Comment