I'm making a portfolio and want to simply print a next & previous project link on each project detail page using DocPad (which uses Backbone collections). The code here is from the my template projects.html.eco. The @document object is the document currently being viewed.
<% for document in @getCollection('projects').toJSON() : %>
<% if document.url.indexOf('/posts') is @document.url.indexOf('/projects') + 1: %>
<a href="<%= document.url %>" class="next"><img src="/images/rt_arrow.png" alt="" /></a>
<% end %>
<% if document.url.indexOf('/posts') is @document.url.indexOf('/projects') - 1: %>
<a href="<%= document.url %>" class="previous"><img src="/images/lft_arrow.png" alt="" /></a>
<% end %>
<% end %>
Let me know if I can provide any more information!
Thank you!