Created
November 16, 2012 15:50
-
-
Save brianmcallister/4088394 to your computer and use it in GitHub Desktop.
Custom Sass function for Array#include?
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
module Sass::Script::Functions | |
# Wrapper around Ruby's Array#include? method. | |
# https://gist.github.com/4088394 | |
# | |
# value - Value to check for in the list. | |
# list - List to look through. | |
# | |
# Examples | |
# | |
# $list: a b c; | |
# @debug contains(b, $list); | |
# # => true | |
# | |
# Returns True if the value is found in the list, false if it isn't. | |
def contains(value, list) | |
assert_type list, :List | |
Sass::Script::Bool.new(list.value.include?(value)) | |
end | |
declare :contains, [:value, :list] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment