Module: Compass::Core::SassExtensions::Functions::Selectors

### Home Classes Methods

### In Files

- lib/compass/core/sass_extensions/functions/selectors.rb

### Methods

- #append_selector
- #headers
- #headings
- #nest

### Class/Module Index

Quicksearch

- Compass
- Compass::BrowserSupport
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Watch
- Compass::Core
- Compass::Core::CanIUse
- Compass::Core::SassExtensions
- Compass::Core::SassExtensions::Functions
- Compass::Core::SassExtensions::Functions::Colors
- Compass::Core::SassExtensions::Functions::Configuration
- Compass::Core::SassExtensions::Functions::Constants
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::Core::SassExtensions::Functions::Display
- Compass::Core::SassExtensions::Functions::Enumerate
- Compass::Core::SassExtensions::Functions::Env
- Compass::Core::SassExtensions::Functions::Files
- Compass::Core::SassExtensions::Functions::FontFiles
- Compass::Core::SassExtensions::Functions::GradientSupport
- Compass::Core::SassExtensions::Functions::GradientSupport::Assertions
- Compass::Core::SassExtensions::Functions::GradientSupport::CSS3AngleToSVGConverter
- Compass::Core::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::Core::SassExtensions::Functions::GradientSupport::Functions
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::Core::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::Core::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::Core::SassExtensions::Functions::ImageSize
- Compass::Core::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::Core::SassExtensions::Functions::ImageSize::JPEG
- Compass::Core::SassExtensions::Functions::InlineImage
- Compass::Core::SassExtensions::Functions::Lists
- Compass::Core::SassExtensions::Functions::Math
- Compass::Core::SassExtensions::Functions::SassDeclarationHelper
- Compass::Core::SassExtensions::Functions::Selectors
- Compass::Core::SassExtensions::Functions::Urls
- Compass::Core::SassExtensions::Functions::Urls::FontUrl
- Compass::Core::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::Core::SassExtensions::Functions::Urls::ImageUrl
- Compass::Core::SassExtensions::Functions::Urls::StylesheetUrl
- Compass::Error
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::HasDeprecatedConstantsFromCore
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::Util
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Tree
- Sass::Tree::Node

No matching classes.

# Compass::Core::SassExtensions::Functions::Selectors

### Constants

COMMA_SEPARATOR

### Public Instance Methods

append_selector(selector, to_append) click to toggle source

Permute two selectors, the first may be comma delimited. The end result is a new selector that is the equivalent of nesting the second selector under the first one in a sass file and preceding it with an &. To illustrate, the following mixins are equivalent, except the second mixin handles:

    @include mixin-a($selector, $to-append) {
      #{$selector} {
        &#{$to-append} {
          width: 2px
        }
      }
    }

    @include mixin-b($selector, $to-append) {
      #{append_selector($selector, $to-append)} {
        width: 2px
      }
    }

    # File lib/compass/core/sass_extensions/functions/selectors.rb, line 50
    def append_selector(selector, to_append)
      ancestors = selector.value.split(COMMA_SEPARATOR)
      descendants = to_append.value.split(COMMA_SEPARATOR)
      nested = ancestors.map{|a| descendants.map{|d| "#{a}#{d}"}.join(", ")}.join(", ")
      unquoted_string(nested)
    end

headers(from = nil, to = nil) click to toggle source

Return the header selectors for the levels indicated Defaults to all headers h1 through h6 For example: headers(all) => h1, h2, h3, h4, h5, h6 headers(4) => h1, h2, h3, h4 headers(2,4) => h2, h3, h4

    # File lib/compass/core/sass_extensions/functions/selectors.rb, line 63
    def headers(from = nil, to = nil)
      if from && !to
        if from.is_a?(Sass::Script::Value::String) && from.value == "all"
          from = number(1)
          to = number(6)
        else
          to = from
          from = number(1)
        end
      else
        from ||= number(1)
        to ||= number(6)
      end
      list((from.value..to.value).map{|n| identifier("h#{n}")}, :comma)
    end

Also aliased as: headings
headings(from = nil, to = nil) click to toggle source
Alias for: headers
nest(*arguments) click to toggle source

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:

    @include mixin-a($selector1, $selector2, $selector3) {
      #{$selector1} {
        #{$selector2} {
          #{$selector3} {
            width: 2px
          }
        }
      }
    }
    @include mixin-b($selector1, $selector2, $selector3) {
      #{nest($selector, $selector2, $selector3)} {
        width: 2px
      }
    }

    # File lib/compass/core/sass_extensions/functions/selectors.rb, line 22
    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
      unquoted_string(nested)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.