class Sass::Script::String

A SassScript object representing a CSS string or a CSS identifier.

def context=(context)

Other tags:
    See: Node#context= -
def context=(context)
  super
  @type = :identifier if context == :equals
end

def initialize(value, type = :identifier)

Parameters:
  • type (Symbol) -- See \{#type}
  • value (String) -- See \{#value}
def initialize(value, type = :identifier)
  super(value)
  @type = type
end

def plus(other)

Other tags:
    See: Literal#plus -
def plus(other)
  other_str = other.is_a?(Sass::Script::String) ? other.value : other.to_s
  Sass::Script::String.new(self.value + other_str, self.type)
end

def to_s(opts = {})

Other tags:
    See: Node#to_s -
def to_s(opts = {})
  if self.type == :identifier
    return %q{""} if context == :equals && self.value.size == 0
    return self.value.gsub("\n", " ")
  end
  return "\"#{value.gsub('"', "\\\"")}\"" if opts[:quote] == %q{"}
  return "'#{value.gsub("'", "\\'")}'" if opts[:quote] == %q{'}
  return "\"#{value}\"" unless value.include?('"')
  return "'#{value}'" unless value.include?("'")
  "\"#{value.gsub('"', "\\\"")}\"" #'
end

def to_sass(opts = {})

Other tags:
    See: Node#to_sass -
def to_sass(opts = {})
  if self.type == :identifier && context == :equals &&
      self.value !~ Sass::SCSS::RX::URI &&
      Sass::SCSS::RX.escape_ident(self.value).include?(?\\)
    return "unquote(#{Sass::Script::String.new(self.value, :string).to_sass})"
  else
    return to_s
  end
end