Add a new helper function to reject values from a list.

This commit is contained in:
Chris Eppstein 2011-12-23 16:53:48 -08:00
parent fc46730b36
commit ca59adfa12
2 changed files with 6 additions and 1 deletions

View File

@ -76,7 +76,7 @@ module Compass::SassExtensions::Functions::Lists
# removes the given values from the list.
def reject(list, *values)
Sass::Script::List.new(list.values.reject{|v| values.any?{|o| v == o}}, list.separator)
Sass::Script::List.new(list.value.reject{|v| values.any?{|o| v == o}}, list.separator)
end
# returns the first value of a space delimited list.

View File

@ -95,6 +95,11 @@ class SassExtensionsTest < Test::Unit::TestCase
assert_equal "true", evaluate("prefixed(-css2, css2-fallback(css3, css2))")
end
def test_reject
assert_equal "b d", evaluate("reject(a b c d, a, c)")
assert_equal "a b c d", evaluate("reject(a b c d, e)")
end
protected
def evaluate(value)
Sass::Script::Parser.parse(value, 0, 0).perform(Sass::Environment.new).to_s