The following example shows how to use for loop to iterate through an array in ejs templating engine.
It generates an output as follows:
I have tried several for loops. But this seems to work consistently in most use-cases.
Project Weekay | Resume | LinkedIn Profile
NodeJS, AWS, MongoDB, ReactJS, Django, Python, ML with Scikit Learn, Matplotlib, Seaborn
Engineering, UX, Marketing, Product Designing, Business
sayhellotovinit@gmail.com | +91 99239 08880 | Pune, India
<!doctype html>
<html>
<head>
<title>Let's Use EJS</title>
</head>
<body>
<h1>My Favorite Things</h1>
<ul>
<% favoriteThings.forEach(function(thing){ %>
<li><%= thing %></li>
<% }) %>
</ul>
</body>
</html>
<!doctype html>
<html>
<head>
<title>Let's Use EJS</title>
</head>
<body>
<h1>My Favorite Things</h1>
<ul>
<li>NYC</li>
<li>Music</li>
<li>Code</li>
<li>Movies</li>
</ul>
</body>
</html>
Comments
Post a Comment