Hope you understand a bit of EJS now. Well, we have a problem right now. What if we need to pass multiple data to the view? What to do then ?
Don’t worry solution is easy. Let’s suppose, we’ll show the person age, job and hobbies in the profile page. So how we can do it ?
First we need to create an object which contains all the data. So just call it data
Now we can pass the data after person using render function.
Let’s start with the age. We’ll print the age in the frontend
See the result in browser
Now let finish the whole thing, it’s pretty easy. but we need to know that to write javascript we use <% to start and %> to end and for printing a variable value we use <%= variable %>
See the result in browser
So do you think you can make some simple project right now ?
You can see the graphical version here
Originally it published on nerdjfpbblog. You can connect with me in twitter or linkedin !
Top comments (0)