└── README.md
/README.md:
--------------------------------------------------------------------------------
1 | # My Embedded Javascript (ejs) Documentation
2 |
3 | ### Total Chapters are following
4 |
5 | 1. Introduction ejs
6 | 2. Passing data
7 | 3. if else
8 | 4. loop
9 | 5. layout
10 | 6. styling
11 | 7. deploy on heroku
12 |
13 |
14 |
15 | ### [1. Introduction to ejs](https://youtu.be/x9o3fxS_xdM)
16 |
17 | #### What is ejs & Why ejs?
18 |
19 | - ejs stands for embedded javascript
20 | - ejs is a templating language.
21 | - templating language helps us to manipulate dynamic content in HTML document.
22 | - Templating language: ejs, handlebars, pug etc.
23 | - Ejs allows us to run plain js in HTML
24 | - Ejs simple, light weight, fast
25 | - Most downloaded templating language on npm
26 | - Founded in Feb, 2011
27 | - how to use ejs
28 |
29 | ```js
30 | // first install ejs:
31 | npm install ejs
32 |
33 | // inside the server
34 | app.set('view engine', 'ejs');
35 |
36 | // create index.ejs inside views folder
37 | res.render('index',{});
38 |
39 | ```
40 |
41 | ### [2. Passing data to ejs]()
42 |
43 | - create and pass the data
44 | - syntax: `<%= variable %>`
45 |
46 | ```js
47 | let pLanguages = ["c", "c++"];
48 |
49 | app.get("/", (req, res) => {
50 | res.render("index", { plNames: pLanguages });
51 | });
52 |
53 | //inside the index.ejs
54 |
no data found
74 | <% } %> 75 | ``` 76 | 77 | ### [4. loop in ejs]() 78 | 79 | - loop control statement 80 | - syntax: 81 | 82 | ```js 83 | <% for () { %> 84 | // do whatever 85 | <% } %> 86 | ``` 87 | 88 | ```js 89 | <% for(let x=0; x