what is this happening .It showing me this error Could not find matching close tag for "<%"

Viewed 57

EJS template code,Where the hell is the problem!!!

<ul>
<%if(<%=itemslist[0]%>!=""){%>

<%for(let i=0;i<=<%=itemslist.length%>;i++){%>
<li> <%=itemslist[i]%> </li>
<%}%>  

<%}%>
 </ul>
2 Answers

Don't use ejs blocks inside of ejs blocks:

<ul>
<%if(itemslist[0]!=""){%>

<%for(let i=0;i<=itemslist.length;i++){%>
<li> <%=itemslist[i]%> </li>
<%}%>  

<%}%>
 </ul>

Not familiar with this style but I would guess it is the nesting of the <% %> tags. Does it work if you remove the <%= %> like below?

  <%if(itemslist[0]!=""){%>
    <%for(let i=0;i<=itemslist.length;i++){%>
      <li> <%=itemslist[i]%> </li>
    <%}%>
  <%}%>
Related