Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add a group_by filter. #1738

Closed
wants to merge 5 commits into
from

Conversation

Projects
None yet
3 participants
Owner

parkr commented Nov 20, 2013

CAUTION: current code is total crap. Don't code tired, kiddies.

mojombo#1735

Owner

parkr commented Nov 20, 2013

@mattr- I think I'm going to need your thoughts on this one. Code could definitely be loads better but my tired mind isn't interested in building it right now.

Owner

parkr commented Nov 20, 2013

Also /cc @Haacked

@mattr- mattr- commented on an outdated diff Nov 23, 2013

lib/jekyll/filters.rb
@@ -158,6 +158,30 @@ def jsonify(input)
input.to_json
end
+ # Group an array of items by a property
+ #
+ # input - the inputted Enumerable
+ # property - the property
+ #
+ # Returns an array of Hashes, each looking something like this:
+ # {"name" => "larry"
+ # "items" => [...] } # all the items where `property` == "larry"
+ def group_by(input, property)
+ if input.respond_to?(:group_by)
@mattr-

mattr- Nov 23, 2013

Owner

perhaps:

if groupable?(input)

where groupable is defined as:

def groupable?(element)
  element.respond_to?(:group_by)
end
Owner

parkr commented Dec 5, 2013

@mattr- Did everything else look OK to you?

Owner

mattr- commented Dec 6, 2013

I think so. I'll look at it again.

Owner

parkr commented Dec 6, 2013

@mattr- Awesome, thanks! Please comment on the weird spots or merge if it's good. :)

parkr added some commits Dec 8, 2013

@parkr parkr Merge pull request #1787 from mojombo/css-includes-2
Move jekyllrb.com CSS to includes & Update Normalize.css to v2.1.3
d2dc52b
@parkr parkr Update history to reflect merge of #1787 d2e9486
@parkr parkr Merge branch 'group-by-filter' of github.com:mojombo/jekyll into grou…
…p-by-filter

* 'group-by-filter' of github.com:mojombo/jekyll:
  Add groupable? method, props @mattr-
  First (terrible) pass at a group_by filter.
346a12d

@parkr parkr closed this Dec 8, 2013

@parkr parkr deleted the group-by-filter branch Dec 8, 2013

@jekyllbot jekyllbot locked and limited conversation to collaborators Feb 27, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.