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

### Home Classes Methods

### In Files

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

### Methods

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

### Class/Module Index

Quicksearch

- Compass
- Compass::Actions
- Compass::AppIntegration
- Compass::AppIntegration::Helpers
- Compass::AppIntegration::Rails
- Compass::AppIntegration::StandAlone
- Compass::AppIntegration::StandAlone::ConfigurationDefaults
- Compass::AppIntegration::StandAlone::Installer
- Compass::BrowserSupport
- Compass::Commands
- Compass::Commands::Base
- Compass::Commands::CleanProject
- Compass::Commands::CleanProjectOptionsParser
- Compass::Commands::CompileProjectOptionsParser
- Compass::Commands::ConfigurationOptionsParser
- Compass::Commands::CreateProject
- Compass::Commands::CreateProjectOptionsParser
- Compass::Commands::Default
- Compass::Commands::DefaultOptionsParser
- Compass::Commands::ExtensionCommand
- Compass::Commands::ExtensionOptionsParser
- Compass::Commands::ExtensionsOptionParser
- Compass::Commands::GenerateGridBackground
- Compass::Commands::GridBackgroundOptionsParser
- Compass::Commands::Help
- Compass::Commands::HelpOptionsParser
- Compass::Commands::Imports
- Compass::Commands::InstallerCommand
- Compass::Commands::Interactive
- Compass::Commands::InteractiveOptionsParser
- Compass::Commands::ListFrameworks
- Compass::Commands::MemoryDebugger
- Compass::Commands::PrintVersion
- Compass::Commands::ProjectBase
- Compass::Commands::ProjectStats
- Compass::Commands::Registry
- Compass::Commands::Sprite
- Compass::Commands::SpriteOptionsParser
- Compass::Commands::StampPattern
- Compass::Commands::StampPatternOptionsParser
- Compass::Commands::StatsOptionsParser
- Compass::Commands::StructureOptionsParser
- Compass::Commands::UnpackExtension
- Compass::Commands::UpdateProject
- Compass::Commands::ValidateProject
- Compass::Commands::ValidationOptionsParser
- Compass::Commands::VersionOptionsParser
- Compass::Commands::WatchProject
- Compass::Commands::WatchProjectOptionsParser
- Compass::Commands::WriteConfiguration
- Compass::Compiler
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Comments
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::FileData
- Compass::Configuration::Helpers
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Serialization
- Compass::Error
- Compass::Exec
- Compass::Exec::CommandOptionParser
- Compass::Exec::GlobalOptionsParser
- Compass::Exec::Helpers
- Compass::Exec::ProjectOptionsParser
- Compass::Exec::SubCommandUI
- Compass::Exec::SwitchUI
- Compass::FilesystemConflict
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::GridBuilder
- Compass::Installers
- Compass::Installers::BareInstaller
- Compass::Installers::Base
- Compass::Installers::Manifest
- Compass::Installers::Manifest::Entry
- Compass::Installers::ManifestInstaller
- Compass::Installers::TemplateContext
- Compass::Logger
- Compass::MissingDependency
- Compass::NullLogger
- Compass::PNG
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::SassExtensions::Functions::Colors
- Compass::SassExtensions::Functions::Constants
- Compass::SassExtensions::Functions::CrossBrowserSupport
- Compass::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::SassExtensions::Functions::Display
- Compass::SassExtensions::Functions::Enumerate
- Compass::SassExtensions::Functions::Env
- Compass::SassExtensions::Functions::FontFiles
- Compass::SassExtensions::Functions::GradientSupport
- Compass::SassExtensions::Functions::GradientSupport::Assertions
- Compass::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::SassExtensions::Functions::GradientSupport::Functions
- Compass::SassExtensions::Functions::GradientSupport::Gradient
- Compass::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::SassExtensions::Functions::ImageSize
- Compass::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::SassExtensions::Functions::ImageSize::JPEG
- Compass::SassExtensions::Functions::InlineImage
- Compass::SassExtensions::Functions::Lists
- Compass::SassExtensions::Functions::Math
- Compass::SassExtensions::Functions::Selectors
- Compass::SassExtensions::Functions::Sprites
- Compass::SassExtensions::Functions::Sprites::VariableReader
- Compass::SassExtensions::Functions::Urls
- Compass::SassExtensions::Functions::Urls::FontUrl
- Compass::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::SassExtensions::Functions::Urls::ImageUrl
- Compass::SassExtensions::Functions::Urls::StylesheetUrl
- Compass::SassExtensions::Sprites
- Compass::SassExtensions::Sprites::ChunkyPngEngine
- Compass::SassExtensions::Sprites::Engine
- Compass::SassExtensions::Sprites::Image
- Compass::SassExtensions::Sprites::ImageMethods
- Compass::SassExtensions::Sprites::ImageRow
- Compass::SassExtensions::Sprites::LayoutMethods
- Compass::SassExtensions::Sprites::RowFitter
- Compass::SassExtensions::Sprites::SpriteMap
- Compass::SassExtensions::Sprites::SpriteMethods
- Compass::SpriteException
- Compass::SpriteImporter
- Compass::Sprites
- Compass::Sprites::Binding
- Compass::Stats
- Compass::Stats::CssFile
- Compass::Stats::SassFile
- Compass::Stats::StatsVisitor
- Compass::TestCase
- Compass::Util
- Compass::Version
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Tree
- Sass::Tree::Node
- QuickCache

No matching classes.

# Compass::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:

# mixin-a(!selector, !to_append)

    #{!selector}
      &#{!to_append}
        width: 2px

# mixin-b(!selector, !to_append)

    #{append_selector(!selector, !to_append)}
      width: 2px

    # File lib/compass/sass_extensions/functions/selectors.rb, line 35
    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(", ")
      Sass::Script::String.new(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/sass_extensions/functions/selectors.rb, line 48
    def headers(from = nil, to = nil)
      if from && !to
        if from.is_a?(Sass::Script::String) && from.value == "all"
          from = Sass::Script::Number.new(1)
          to = Sass::Script::Number.new(6)
        else
          to = from
          from = Sass::Script::Number.new(1)
        end
      else
        from ||= Sass::Script::Number.new(1)
        to ||= Sass::Script::Number.new(6)
      end
      Sass::Script::String.new((from.value..to.value).map{|n| "h#{n}"}.join(", "))
    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:

# mixin-a(!selector1, !selector2, !selector3)

    #{!selector1}
      #{selector2}
        #{selector3}
          width: 2px

# mixin-b(!selector1, !selector2)

    #{nest(!selector, !selector2, !selector3)}
      width: 2px

    # File lib/compass/sass_extensions/functions/selectors.rb, line 15
    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

[Validate]

Generated with the Darkfish Rdoc Generator 2.