2014-12-17 4 views
0

내가 밑줄 템플릿에 루프에서 if 문이를 추가하기 위해 노력하고있어 경우 :밑줄 루프 내에서 문이

<% _.each(looks, function(listItem, index){ %> 
      <% if(_.contains(firstBatch, listItem.id)){ %> 
       <% if (index % 2 == 0) { %> 
         <div class="large-6 column overlay-col"> 
       <% } else { %> 
         <div class=" column overlay-col"> 
       <% } % %> 
      <% } %>                 
<% }) %> 

기본적으로는 지수가 짝수 인 경우 감지하지만 나는이 콘솔 오류가 발생합니다 :

SyntaxError: missing : after property id 
if (index % 2 === 0) { 

코드에 어떤 문제가 있습니까?

<% } % %> 

여분 %가 기능 :

답변

1

나는 당신의 구문이 7 행에 멍청이가 있다고 생각?

당신이 기능의 주위에 모든 장식을 제거 할 때이 분명해집니다 :

_.each(looks, function(listItem, index){  
    if(_.contains(firstBatch, listItem.id)){ 
    if (index % 2 == 0) { 
     <div class="large-6 column overlay-col"> 
    } else { 
     <div class=" column overlay-col"> 
    } % 
    }                 
}) 
+0

덕분에, 저 바보! – user1937021

관련 문제