Class | Sass::Script::Interpolation
In: | lib/sass/script/interpolation.rb
Parent: | Node

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

@see StringInterpolation

### Methods

_perform children inspect new to_sass

### Public Class methods

new(before, mid, after, wb, wa, originally_text = false)

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

@param before [Node] The SassScript before the interpolation @param mid [Node] The SassScript within the interpolation @param after [Node] The SassScript after the interpolation @param wb [Boolean] Whether there was whitespace between `before` and `#{` @param wa [Boolean] Whether there was whitespace between `}` and `after` @param originally_text [Boolean]

      Whether the original format of the interpolation was plain text,
      not an interpolation.
      This is used when converting back to SassScript.

[Source]

        # File lib/sass/script/interpolation.rb, line 17
    17:     def initialize(before, mid, after, wb, wa, originally_text = false)
    18:       @before = before
    19:       @mid = mid
    20:       @after = after
    21:       @whitespace_before = wb
    22:       @whitespace_after = wa
    23:       @originally_text = originally_text
    24:     end

### Public Instance methods

children()

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

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

[Source]

        # File lib/sass/script/interpolation.rb, line 49
    49:     def children
    50:       [@before, @mid, @after].compact
    51:     end

inspect()

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

[Source]

        # File lib/sass/script/interpolation.rb, line 27
    27:     def inspect
    28:       "(interpolation #{@before.inspect} #{@mid.inspect} #{@after.inspect})"
    29:     end

to_sass(opts = {})

@see Node#to_sass

[Source]

        # File lib/sass/script/interpolation.rb, line 32
    32:     def to_sass(opts = {})
    33:       res = ""
    34:       res << @before.to_sass(opts) if @before
    35:       res << ' ' if @before && @whitespace_before
    36:       res << '#{' unless @originally_text
    37:       res << @mid.to_sass(opts)
    38:       res << '}' unless @originally_text
    39:       res << ' ' if @after && @whitespace_after
    40:       res << @after.to_sass(opts) if @after
    41:       res
    42:     end

### Protected Instance methods

_perform(environment)

Evaluates the interpolation.

@param environment [Sass::Environment] The environment in which to evaluate the SassScript @return [Sass::Script::String] The SassScript string that is the value of the interpolation

[Source]

        # File lib/sass/script/interpolation.rb, line 59
    59:     def _perform(environment)
    60:       res = ""
    61:       res << @before.perform(environment).to_s if @before
    62:       res << " " if @before && @whitespace_before
    63:       val = @mid.perform(environment)
    64:       res << (val.is_a?(Sass::Script::String) ? val.value : val.to_s)
    65:       res << " " if @after && @whitespace_after
    66:       res << @after.perform(environment).to_s if @after
    67:       Sass::Script::String.new(res)
    68:     end

[Validate]