1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7+ < link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css "/>
8+ < link rel ="stylesheet " href ="https://use.fontawesome.com/releases/v5.15.2/css/all.css "
9+ integrity ="sha384-vSIIfh2YWi9wW0r9iZe7RJPrKwp6bG+s9QZMoITbCckVJqGCCRhc+ccxNcdpHuYu " crossorigin ="anonymous ">
10+ < link href ="
https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap.min.css "
rel ="
stylesheet "
11+ integrity ="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl " crossorigin ="anonymous ">
12+ < title > HandleBars</ title >
13+ </ head >
14+ < body class ="container-fluid bg-primary p-2 ">
15+ < main class ="container-fluid bg-white p-2 ">
16+ < h1 > < u > 03 - HandleBars</ u > </ h1 >
17+ < div class ="container ">
18+ < pre class ="bg-dark text-white p-3 ">
19+ // Templating:
20+ // ===========
21+ // Templating is used to reuse HTML code to display
22+ // similar web pages. For Templating, we can use any
23+ // of the various Templating engines like EJS, HandleBars(hbs), etc.
24+
25+ // here, we have installed hbs npm package,
26+ npm i hbs
27+ // Now, mostly all things will be same as in was for ejs but
28+ // some changes will be there like:
29+ // 1> while refrencing the passed objects in home.hbs and other
30+ // UI/views files, we will use them like this {{ PassedObjectName }}
31+ // rather than refrencing them like ⟩%= PassedObjectName %>
32+ // 2> we will use the loops as we used them in home.hbs file:
33+
34+ ⟨ul>
35+ {{#each HomeArray}}
36+ ⟨li> {{this}} ⟨/li>
37+ {{/each}}
38+ ⟨/ul>
39+
40+ // now, create folder "views" inside your project directory.
41+ // and inside views, create home.ejs and subreddit.hbs file.
42+ < a href ="./views/home.hbs "> home.hbs</ a >
43+ < a href ="./views/subreddit.hbs "> subreddit.hbs</ a >
44+
45+ // See in below index.js file on
46+ // how we can use and work with HandleBars Templates,
47+ < a href ="./index.js "> index.js</ a >
48+
49+ </ pre >
50+ </ div >
51+ </ main >
52+ < footer class ="p-3 ">
53+ < p class ="d-block text-center text-white "> Next:
54+ < a class ="text-white " href ="./../../index.html "> Go back to Web-Development Hompepage</ a > </ p >
55+ </ footer >
56+ < script >
57+ </ script >
58+ </ body >
59+ </ html >
0 commit comments