compass/src/test/testData/gems/compass-0.13.alpha.2/lib/compass/sass_extensions/functions/selectors.rb
# Permute multiple selectors each of which may be comma delimited, the end result is
# a new selector that is the equivalent of nesting each under the previous selector.
# To illustrate, the following mixins are equivalent:
# =mixin-a(!selector1, !selector2, !selector3)
#   #{!selector1}
#     #{selector2}
#       #{selector3}
#         width: 2px
# =mixin-b(!selector1, !selector2)
#   #{nest(!selector, !selector2, !selector3)}
#     width: 2px
Permute multiple selectors each of which may be comma delimited, the end result is
a new selector that is the equivalent of nesting each under the previous selector.
Permute multiple selectors each of which may be comma delimited the end result is a new selector that is the equivalent of nesting each under the previous selector .
def nest(*arguments)
    nested = arguments.map{|a| a.value}.inject do |memo,arg|
      ancestors = memo.split(COMMA_SEPARATOR)
      descendants = arg.split(COMMA_SEPARATOR)
      ancestors.map{|a| descendants.map{|d| "#{a} #{d}"}.join(", ")}.join(", ")
    end
    Sass::Script::String.new(nested)
  end
def nest ( * arguments ) nested = arguments . map { | a | a . value } . inject do | memo , arg | ancestors = memo . split ( COMMA_SEPARATOR ) descendants = arg . split ( COMMA_SEPARATOR ) ancestors . map { | a | descendants . map { | d | "#{a} #{d}" } . join ( ", " ) } . join ( ", " ) end Sass :: Script :: String . new ( nested ) end
Permute multiple selectors each of which may be comma delimited, the end result is
a new selector that is the equivalent of nesting each under the previous selector.
Permute multiple selectors each of which may be comma delimited the end result is a new selector that is the equivalent of nesting each under the previous selector .
arguments