RandomEtc/ejs-locals

If/else and Switch operator

Opened this issue ยท 2 comments

Do not understand, but i have errors, while use switch or if/else op...
Somethin like this :
<% switch ( state ) { %>
   <% case 0: %>
    

some text


   <% break; %>
   <% case 1: %>
     

another one


   <% break; %>
<% } %>
or this :
<% if (state == 0) { %>
  

First state


<% } %>
<% else if (state == 1) { %>
  

Second state


<% } %>
but simple 'if' op is works
Error: " SyntaxError: Unexpected token ; "

This is a really old issue, but if you are still having this issue, from my experience you need to group the closing bracket with the else like so <% } else { %> instead of <% } %> <% else { %>

same here:

<%switch (item.tipo) { %>
<%case 1:%>

won't work while

<%switch (item.tipo) {
case 1:%>

works fine (independently of the rest of the code)