Created
January 20, 2012 20:20
-
-
Save alenm/1649365 to your computer and use it in GitHub Desktop.
Toto Archive Group_by
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------ | |
# 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