Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add where filter to filter arrays of objects #1749

Closed
wants to merge 2 commits into from
Closed

Add where filter to filter arrays of objects #1749

wants to merge 2 commits into from

Conversation

benbalter
Copy link
Contributor

Along with #1738, fixes #1735.

Usage:

Output all pages with the layout staff as JSON:

{{ site.pages | where:"layout","staff" | jsonify }}

@parkr
Copy link
Member

parkr commented Nov 23, 2013

👍

#
# Returns the filtered array of objects
def where(input, key, value)
return input unless input.class == Array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make more sense to use is_a?:

unless input.is_a?(Array)

Reads a bit more nicely. :)

@parkr
Copy link
Member

parkr commented Dec 5, 2013

Needs review by @mattr-

@parkr
Copy link
Member

parkr commented Dec 10, 2013

Would you mind rebasing? Looks like #1788 messed this up. Sorry about that!

Conflicts:
	lib/jekyll/filters.rb
@benbalter
Copy link
Contributor Author

Rebase'd.

@mattr- mattr- closed this in #1875 Jan 4, 2014
luzbel added a commit to luzbel/Cuaderno-de-bitacora that referenced this pull request Nov 16, 2016
@jekyll jekyll 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add filter and grouping support
3 participants