If you have any query feel free to chat us!
Happy Coding! Happy Learning!
EJS (Embedded JavaScript) is a simple templating language that lets you generate HTML markup with plain JavaScript. It's easy to use and provides a lot of features to make it flexible and powerful.
Here are some basic examples of how to use EJS:
Outputting Variables:
In EJS, you can output the value of a variable by placing it inside <% %> tags. For example, to output the value of a variable named "title", you can use the following code:
htmlCopy code
<h1><%= title %></h1>
Conditional Statements:
You can use conditional statements in EJS to generate different content based on certain conditions. For example, to generate content only if a variable "isLoggedIn" is true, you can use the following code:
htmlCopy code
<% if(isLoggedIn) { %>
<p>Welcome back!</p>
<% } %>
Looping over Arrays:
You can loop over arrays in EJS using the <% %> tags and the JavaScript forEach() method. For example, to generate a list of items from an array named "items", you can use the following code:
htmlCopy code
<ul>
<% items.forEach(function(item) { %>
<li><%= item %></li>
<% }); %>
</ul>
Including Partials:
EJS allows you to include partial templates using the <% include %> tag. For example, to include a header and a footer partial in your template, you can use the following code:
htmlCopy code
<% include header %>
<h1><%= title %></h1>
<% include footer %>
These are just a few examples of what you can do with EJS. With its simple syntax and powerful features, it's a great choice for generating dynamic HTML content in Node.js applications.
Comments: 2
I am not able to access videos from second class and further. I have already completed first class
When will I get my course?
Now, Your query was resolved.