Sha256: d97c8693847cf950d634bcdb279562820c3c597e6930d8fd15170d368885da14

Contents?: true

Size: 682 Bytes

Versions: 2

Compression:

Stored size: 682 Bytes

Contents

PSEUDO_ELEMENTS = File.read(File.realpath(File.join(File.dirname(__FILE__), "..", "..", "..", "data", "pseudo_elements.txt"))).split("\n")

class SCSSBeautifier::Formatters::PseudoElement < Sass::Tree::Visitors::Base
  def visit_rule(node)
    check_pseudo(node) if node.rule.join.match(/::?/)
    visit_children(node)
  end

  def check_pseudo(node)
    node.rule = Sass::Util.strip_string_array(node.rule.map { |r|
      return r unless r.is_a?(String)
      require_double_colon = PSEUDO_ELEMENTS.index(r.split(":").last)

      colon_type = require_double_colon ? '::' : ':'

      r.gsub(/::?/, colon_type)
    })

    node.send(:try_to_parse_non_interpolated_rules)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scss_beautifier-0.1.11 lib/scss_beautifier/formatters/pseudo_element.rb
scss_beautifier-0.1.10 lib/scss_beautifier/formatters/pseudo_element.rb