Reputation: 41
I have two objects that I am trying to render via EJS. I am wondering if it is possible to render them in the same pair of scriptlet tags or if i have to render them in separate pairs?
I can successfuly render the objects currentDay and typeOfDay in separate scriptlet tags:
<h1>Today is <%= currentDay%>. It's a <%= typeOfDay %></h1>
But it does not work in the same scriptlet, only the first object will be rendered when I use:
<h1>Today is <%= currentDay, typeOfDay%> </h1>
Can I use one pair or isn't possible?
res.render('index', {
currentDay: currentDay,
typeOfDay: typeOfDay
})
Upvotes: 0
Views: 194
Reputation: 396
You could write a JavaScript template literal:
<h1>Today is <%= `${currentDay}, ${typeOfDay}` %></h1>
Upvotes: 1