module Sass::Script::Functions

Public Instance Methods

escape(data, options = {}) click to toggle source

Return a string containing the escaped version of the provided data for use as a CSS identifier

# File lib/sassy-escape.rb, line 7
def escape(data, options = {})
  require "cssesc"
  if data.instance_of? Sass::Script::String
    string = data.value.to_s
    type = data.type
  else
    string = data.to_s
    type = :identifier
  end
  options.each_pair { |k, v| options[k] = v.value }
  escaped_string = CSSEsc.escape(string, options)
  Sass::Script::String.new(escaped_string, type)
end