### Home Classes Methods

### In Files

- lib/sass/script/tree/interpolation.rb

### Parent

Sass::Script::Tree::Node

### Methods

- ::new
- #_perform
- #children
- #deep_copy
- #inspect
- #to_sass

### Class/Module Index

Quicksearch

- Sass
- Sass::BaseEnvironment
- Sass::CSS
- Sass::CacheStores
- Sass::CacheStores::Base
- Sass::CacheStores::Chain
- Sass::CacheStores::Filesystem
- Sass::CacheStores::Memory
- Sass::CacheStores::Null
- Sass::Callbacks
- Sass::Callbacks::InstanceMethods
- Sass::Engine
- Sass::Engine::Line
- Sass::Environment
- Sass::Exec
- Sass::Exec::Base
- Sass::Exec::SassConvert
- Sass::Exec::SassScss
- Sass::Exec::SassScss::Sass::Plugin.compiler
- Sass::Features
- Sass::Importers
- Sass::Importers::Base
- Sass::Importers::Filesystem
- Sass::Logger
- Sass::Logger::Base
- Sass::Logger::LogLevel
- Sass::Logger::LogLevel::ClassMethods
- Sass::Media
- Sass::Media::Query
- Sass::Media::QueryList
- Sass::Plugin
- Sass::Plugin::Compiler
- Sass::Plugin::Configuration
- Sass::Plugin::MerbBootLoader
- Sass::Plugin::Rack
- Sass::Plugin::StalenessChecker
- Sass::ReadOnlyEnvironment
- Sass::Repl
- Sass::SCSS
- Sass::SCSS::CssParser
- Sass::SCSS::Parser
- Sass::SCSS::RX
- Sass::SCSS::ScriptLexer
- Sass::SCSS::ScriptParser
- Sass::SCSS::StaticParser
- Sass::Script
- Sass::Script::CssLexer
- Sass::Script::CssParser
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::Lexer
- Sass::Script::Parser
- Sass::Script::Tree
- Sass::Script::Tree::Funcall
- Sass::Script::Tree::Interpolation
- Sass::Script::Tree::ListLiteral
- Sass::Script::Tree::Literal
- Sass::Script::Tree::MapLiteral
- Sass::Script::Tree::Node
- Sass::Script::Tree::Operation
- Sass::Script::Tree::Selector
- Sass::Script::Tree::StringInterpolation
- Sass::Script::Tree::UnaryOperation
- Sass::Script::Tree::Variable
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::Bool
- Sass::Script::Value::Color
- Sass::Script::Value::Helpers
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Script::Value::Null
- Sass::Script::Value::Number
- Sass::Script::Value::String
- Sass::Selector
- Sass::Selector::AbstractSequence
- Sass::Selector::Attribute
- Sass::Selector::Class
- Sass::Selector::CommaSequence
- Sass::Selector::Element
- Sass::Selector::Id
- Sass::Selector::Parent
- Sass::Selector::Placeholder
- Sass::Selector::Pseudo
- Sass::Selector::Sequence
- Sass::Selector::Simple
- Sass::Selector::SimpleSequence
- Sass::Selector::Universal
- Sass::SemiGlobalEnvironment
- Sass::Shared
- Sass::Source
- Sass::Source::Map
- Sass::Source::Map::Mapping
- Sass::Source::Position
- Sass::Source::Range
- Sass::Stack
- Sass::Stack::Frame
- Sass::Supports
- Sass::Supports::Condition
- Sass::Supports::Declaration
- Sass::Supports::Interpolation
- Sass::Supports::Negation
- Sass::Supports::Operator
- Sass::SyntaxError
- Sass::Tree
- Sass::Tree::AtRootNode
- Sass::Tree::CharsetNode
- Sass::Tree::CommentNode
- Sass::Tree::ContentNode
- Sass::Tree::CssImportNode
- Sass::Tree::DebugNode
- Sass::Tree::DirectiveNode
- Sass::Tree::EachNode
- Sass::Tree::ErrorNode
- Sass::Tree::ExtendNode
- Sass::Tree::ForNode
- Sass::Tree::FunctionNode
- Sass::Tree::IfNode
- Sass::Tree::ImportNode
- Sass::Tree::KeyframeRuleNode
- Sass::Tree::MediaNode
- Sass::Tree::MixinDefNode
- Sass::Tree::MixinNode
- Sass::Tree::Node
- Sass::Tree::PropNode
- Sass::Tree::ReturnNode
- Sass::Tree::RootNode
- Sass::Tree::RuleNode
- Sass::Tree::SupportsNode
- Sass::Tree::TraceNode
- Sass::Tree::VariableNode
- Sass::Tree::Visitors
- Sass::Tree::Visitors::Base
- Sass::Tree::Visitors::CheckNesting
- Sass::Tree::Visitors::Convert
- Sass::Tree::Visitors::Cssize
- Sass::Tree::Visitors::Cssize::Bubble
- Sass::Tree::Visitors::DeepCopy
- Sass::Tree::Visitors::Extend
- Sass::Tree::Visitors::Perform
- Sass::Tree::Visitors::SetOptions
- Sass::Tree::Visitors::ToCss
- Sass::Tree::WarnNode
- Sass::Tree::WhileNode
- Sass::UnitConversionError
- Sass::Util
- Sass::Util::CrossPlatformRandom
- Sass::Util::MultibyteStringScanner
- Sass::Util::NormalizedMap
- Sass::Util::StaticConditionalContext
- Sass::Util::SubsetMap
- Sass::Util::Test
- Sass::Version
- ActionController
- ActionController::Base
- Object
- OrderedHash

No matching classes.

# Sass::Script::Tree::Interpolation

A SassScript object representing `#{}` interpolation outside a string.

@see StringInterpolation

### Attributes

after[R]

@return [Node] The SassScript after the interpolation

before[R]

@return [Node] The SassScript before the interpolation

mid[R]

@return [Node] The SassScript within the interpolation

originally_text[R]

@return [Boolean] Whether the original format of the interpolation was

    plain text, not an interpolation. This is used when converting back to
    SassScript.

warn_for_color[R]

@return [Boolean] Whether a color value passed to the interpolation should

    generate a warning.

whitespace_after[R]

@return [Boolean] Whether there was whitespace between `}` and `after`

whitespace_before[R]

@return [Boolean] Whether there was whitespace between `before` and `#{`

### Public Class Methods

new(before, mid, after, wb, wa, originally_text = false, warn_for_color = false) click to toggle source

Interpolation in a property is of the form `before #{mid} after`.

@param before [Node] See {Interpolation#before} @param mid [Node] See {Interpolation#mid} @param after [Node] See {Interpolation#after} @param wb [Boolean] See {Interpolation#whitespace_before} @param wa [Boolean] See {Interpolation#whitespace_after} @param originally_text [Boolean] See {Interpolation#originally_text} @param warn_for_color [Boolean] See {Interpolation#warn_for_color} @comment

    rubocop:disable ParameterLists

    # File lib/sass/script/tree/interpolation.rb, line 41
    def initialize(before, mid, after, wb, wa, originally_text = false, warn_for_color = false)
      # rubocop:enable ParameterLists
      @before = before
      @mid = mid
      @after = after
      @whitespace_before = wb
      @whitespace_after = wa
      @originally_text = originally_text
      @warn_for_color = warn_for_color
    end

### Public Instance Methods

children() click to toggle source

Returns the three components of the interpolation, `before`, `mid`, and `after`.

@return [Array<Node>] @see initialize @see Node#children

    # File lib/sass/script/tree/interpolation.rb, line 75
    def children
      [@before, @mid, @after].compact
    end

deep_copy() click to toggle source

@see Node#deep_copy

    # File lib/sass/script/tree/interpolation.rb, line 80
    def deep_copy
      node = dup
      node.instance_variable_set('@before', @before.deep_copy) if @before
      node.instance_variable_set('@mid', @mid.deep_copy)
      node.instance_variable_set('@after', @after.deep_copy) if @after
      node
    end

inspect() click to toggle source

@return [String] A human-readable s-expression representation of the interpolation

    # File lib/sass/script/tree/interpolation.rb, line 53
    def inspect
      "(interpolation #{@before.inspect} #{@mid.inspect} #{@after.inspect})"
    end

to_sass(opts = {}) click to toggle source

@see Node#to_sass

    # File lib/sass/script/tree/interpolation.rb, line 58
    def to_sass(opts = {})
      res = ""
      res << @before.to_sass(opts) if @before
      res << ' ' if @before && @whitespace_before
      res << '#{' unless @originally_text
      res << @mid.to_sass(opts)
      res << '}' unless @originally_text
      res << ' ' if @after && @whitespace_after
      res << @after.to_sass(opts) if @after
      res
    end

### Protected Instance Methods

_perform(environment) click to toggle source

Evaluates the interpolation.

@param environment [Sass::Environment] The environment in which to evaluate the SassScript @return [Sass::Script::Value::String]

    The SassScript string that is the value of the interpolation

    # File lib/sass/script/tree/interpolation.rb, line 95
    def _perform(environment)
      res = ""
      res << @before.perform(environment).to_s if @before
      res << " " if @before && @whitespace_before

      val = @mid.perform(environment)
      if @warn_for_color && val.is_a?(Sass::Script::Value::Color) && val.name
        alternative = Operation.new(Sass::Script::Value::String.new("", :string), @mid, :plus)
        Sass::Util.sass_warn WARNING on line #{line}, column #{source_range.start_pos.offset}#{" of #{filename}" if filename}:You probably don't mean to use the color value `#{val}' in interpolation here.It may end up represented as #{val.inspect}, which will likely produce invalid CSS.Always quote color names when using them as strings (for example, "#{val}").If you really want to use the color value here, use `#{alternative.to_sass}'.
      end

      res << val.to_s(:quote => :none)
      res << " " if @after && @whitespace_after
      res << @after.perform(environment).to_s if @after
      opts(Sass::Script::Value::String.new(res))
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.