class Sass::Script::StringInterpolation

@see Interpolation
A SassScript object representing ‘#{}` interpolation within a string.

def _perform(environment)

Returns:
  • (Sass::Script::String) - The SassScript string that is the value of the interpolation

Parameters:
  • environment (Sass::Environment) -- The environment in which to evaluate the SassScript
def _perform(environment)
  res = ""
  before = @before.perform(environment)
  res << before.value
  mid = @mid.perform(environment)
  res << (mid.is_a?(Sass::Script::String) ? mid.value : mid.to_s)
  res << @after.perform(environment).value
  Sass::Script::String.new(res, before.type)
end

def children

Other tags:
    See: Node#children -
    See: #initialize -

Returns:
  • (Array) -
def children
  [@before, @mid, @after].compact
end

def initialize(before, mid, after)

Parameters:
  • after (Node) -- The string after the interpolation
  • mid (Node) -- The SassScript within the interpolation
  • before (Node) -- The string before the interpolation
def initialize(before, mid, after)
  @before = before
  @mid = mid
  @after = after
end

def inspect

Returns:
  • (String) - A human-readable s-expression representation of the interpolation
def inspect
  "(string_interpolation #{@before.inspect} #{@mid.inspect} #{@after.inspect})"
end

def parse_str(str)

def parse_str(str)
  case str
  when /^unquote\((["'])(.*)\1\)$/
    return true, $1, $2
  when '""'
    return false, nil, ""
  when /^(["'])(.*)\1$/
    return false, $1, $2
  else
    return false, nil, str
  end
end

def to_sass(opts = {})

Other tags:
    See: Node#to_sass -
def to_sass(opts = {})
  # We can get rid of all of this when we remove the deprecated :equals context
  before_unquote, before_quote_char, before_str = parse_str(@before.to_sass(opts))
  after_unquote, after_quote_char, after_str = parse_str(@after.to_sass(opts))
  unquote = before_unquote || after_unquote ||
    (before_quote_char && !after_quote_char && !after_str.empty?) ||
    (!before_quote_char && after_quote_char && !before_str.empty?)
  quote_char =
    if before_quote_char && after_quote_char && before_quote_char != after_quote_char
      before_str.gsub!("\\'", "'")
      before_str.gsub!('"', "\\\"")
      after_str.gsub!("\\'", "'")
      after_str.gsub!('"', "\\\"")
      '"'
    else
      before_quote_char || after_quote_char
    end
  res = ""
  res << 'unquote(' if unquote
  res << quote_char if quote_char
  res << before_str
  res << '#{' << @mid.to_sass(opts) << '}'
  res << after_str
  res << quote_char if quote_char
  res << ')' if unquote
  res
end