Sha256: be45929af7501cff5f5b9f032f19137d740e6cb68ea172146ec717b7f83d6361

Contents?: true

Size: 957 Bytes

Versions: 5

Compression:

Stored size: 957 Bytes

Contents

class SCSSBeautifier::Formatters::NameFormat < Sass::Tree::Visitors::Base
  def visit_function(node)
    check_name(node)
  end

  def visit_mixin(node)
    check_name(node)
  end

  def visit_placeholder(node)
    check_name(node)
  end

  def visit_mixindef(node)
    check_name(node)
  end

  def visit_script_funcall(node)
    check_name(node)
  end

  def visit_script_variable(node)
    check_name(node)
  end

  def visit_variable(node)
    check_name(node)
  end

  def visit_rule(node)
    check_rule(node)
  end

  private

  def check_name(node)
    # return unless node.name
    node.instance_variable_set(:@name, Sass::Script::Value::String.new(node.name.to_s.gsub(/[[:upper:]]/) { "-#{$&}" }.downcase.gsub(/_/, '-')))
  end

  def check_rule(node)
    node.rule = Sass::Util.strip_string_array(node.rule.map { |r| r.to_s.gsub(/[[:upper:]]/) { "-#{$&}" }.downcase.gsub(/_/, '-') })
    node.send(:try_to_parse_non_interpolated_rules)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
scss_beautifier-0.1.4 lib/scss_beautifier/formatters/name_format.rb
scss_beautifier-0.1.3 lib/scss_beautifier/formatters/name_format.rb
scss_beautifier-0.1.2 lib/scss_beautifier/formatters/name_format.rb
scss_beautifier-0.1.1 lib/scss_beautifier/formatters/name_format.rb
scss_beautifier-0.1.0 lib/scss_beautifier/formatters/name_format.rb