<% var emotions = currentData.emticons, colNum = (currentData.size == 'small' ? 14 : 7), rowNum = Math.ceil(emotions.length/colNum), item = null; %> <%for(var i = 0; i < rowNum; i++){%> <%for(var j = 0; (j < colNum && i*colNum+j < emotions.length ); j++){%> <% item = emotions[i*colNum+j]%> <%}%> <%}%>