DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Day 25 – Working with EJS (Part 2) - Learning Node JS In 30 Days [Mini series]
Muhammad Ali (Nerdjfpb)
Muhammad Ali (Nerdjfpb)

Posted on • Originally published at blog.nerdjfpb.com

Day 25 – Working with EJS (Part 2) - Learning Node JS In 30 Days [Mini series]

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

Alt Text

Now we can pass the data after person using render function.

Alt Text

Let’s start with the age. We’ll print the age in the frontend

Alt Text

See the result in browser

Alt Text

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 %>

Alt Text

See the result in browser

Alt Text

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 !

You can read the old posts from this series (below)

Top comments (0)

This is your brain on JavaScript (classic DEV post)

brain computer interface

Experimenting with brain-computer interfaces in JavaScript