Skip to content

Instantly share code, notes, and snippets.

@timwis
Created February 25, 2016 15:08
Show Gist options
  • Save timwis/8d2078c62cd3a0b0d8ed to your computer and use it in GitHub Desktop.
Save timwis/8d2078c62cd3a0b0d8ed to your computer and use it in GitHub Desktop.
Jekyll where filter for strings and arrays
def where(input, property, value)
return input unless input.is_a?(Enumerable)
input = input.values if input.is_a?(Hash)
input.select do |object|
input_property = item_property(object, property)
input_property.to_s == value.to_s || Array(input_property).include?(value.to_s)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment