Skip to content

Instantly share code, notes, and snippets.

@alenm
Created January 20, 2012 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alenm/1649365 to your computer and use it in GitHub Desktop.
Save alenm/1649365 to your computer and use it in GitHub Desktop.
Toto Archive Group_by
# ------------------------------------------------------------
# The Toto Archive page has a collection called 'archive'
# We use Ruby's group_by method to enumerate over the collection by :year
# And then iterate through the posts
# ------------------------------------------------------------
<% archives.group_by { | archive | archive[:date].year }.each do | year, posts | %>
<%= year %>
<% for post in posts %>
<a href="<%= post.path %>"><%= post.title %></a>
<% end %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment