Module: Sass::Script::Functions

Defined in:
lib/sass_extensions.rb

Constant Summary collapse

COMMA_SEPARATOR =
/\s*,\s*/

Instance Method Summary collapse

Instance Method Details

#nest(*arguments) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/sass_extensions.rb', line 5

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