Created
February 25, 2016 15:08
-
-
Save timwis/8d2078c62cd3a0b0d8ed to your computer and use it in GitHub Desktop.
Jekyll where filter for strings and arrays
This file contains hidden or 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
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