ejs-locals icon indicating copy to clipboard operation
ejs-locals copied to clipboard

If/else and Switch operator

Open boolka opened this issue 12 years ago • 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 ; "

boolka avatar Apr 26 '14 15:04 boolka

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 { %>

TravestyDesigns avatar Mar 02 '16 02:03 TravestyDesigns

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)

angrykoala avatar Apr 26 '16 10:04 angrykoala