Module: Sass::Script::Functions
- Defined in:
- lib/sass_extensions.rb
Constant Summary collapse
- COMMA_SEPARATOR =
/\s*,\s*/
Instance Method Summary collapse
Instance Method Details
#enumerate(prefix, from, through) ⇒ Object
15 16 17 18 |
# File 'lib/sass_extensions.rb', line 15 def enumerate(prefix, from, through) selectors = (from.value..through.value).map{|i| "#{prefix.value}-#{i}"}.join(", ") Sass::Script::String.new(selectors) end |
#image_url(path) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sass_extensions.rb', line 20 def image_url(path) if absolute_path?(path.value) return Sass::Script::String.new("url(#{path})") end http_images_path = if Compass.configuration.http_images_path == :relative if (target_css_file = [:css_filename]) images_path = File.join(Compass.configuration.project_path, Compass.configuration.images_dir) Pathname.new(images_path).relative_path_from(Pathname.new(File.dirname(target_css_file))).to_s else nil end else Compass.configuration.http_images_path end if http_images_path http_images_path = "#{http_images_path}/" unless http_images_path[-1..-1] == "/" path = "#{http_images_path}#{path}" end Sass::Script::String.new("url(#{path})") end |
#nest(*arguments) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/sass_extensions.rb', line 6 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 |