John
John

Reputation: 480

nested EJS tag. Not working

just a simple question but i cant find anything on it on google.

So here it is,

Why this doesn't work?

on the 1st line, the last '%>' turns white enter image description here

This is from my NodeJS js file. when i render the "loginuserprofile" i passed the userProfile variable to EJS This is from my NodeJS js file and i'll get an error of

Error: Could not find matching close tag for "<%".

i cant use nested <% %>?

Thank you!

Upvotes: 1

Views: 6758

Answers (2)

Michael
Michael

Reputation: 11894

No, you can not use nested <% %>

You need to use just <% if (userProfile.facebook.length === 0) { %>

Like

<% if (userProfile.facebook.length === 0) { %>
    <h1>No Facebook!</h1>
<% } %>

Upvotes: 5

kailash yogeshwar
kailash yogeshwar

Reputation: 834

You don't have to rewrite ejs expression tag again inside if as if statement itself is in expression tag and will render the template variables without any problem.

Upvotes: 3

Related Questions