Reputation: 480
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
This is from my NodeJS js file. when i render the "loginuserprofile" i passed the userProfile variable to EJS 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
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
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