I am using jquery and haml to implement my application. I am displaying a list of avatars but want to restrict the number to be max 8.
<% $.each(question.friends, function(i, e){ %>
<% if (typeof(e) !== 'undefined') { %>
%a{href: "/<%= e.nickname %>", rel: "tooltip", title: "<%= e.nickname %>"}
%img{src: "<%= e.avatar_url%>"}
<% } %>
<% }); %>
How can I update the code above to ensure only 8 is displayed?
iis the index, so just make sure it’s less than 8:Or, if
question.friendsis an array,sliceit to a maximum of 8 elements: