RandomEtc / ejs-locals

Express 3.x layout, partial and block template functions for the EJS template engine.
298 stars 63 forks source link

If/else and Switch operator #40

Open boolka opened 10 years ago

boolka commented 10 years ago

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 ; "

TravestyDesigns commented 8 years ago

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

angrykoala commented 8 years ago

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)