Skip to content

Instantly share code, notes, and snippets.

@brianmcallister
Created November 16, 2012 15:50
Show Gist options
  • Save brianmcallister/4088394 to your computer and use it in GitHub Desktop.
Save brianmcallister/4088394 to your computer and use it in GitHub Desktop.
Custom Sass function for Array#include?
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