Sha256: 74f4d8605fa0c9f6fe76899ee212f36523aad5eab2bd991f0a8133e61467cca8
Contents?: true
Size: 632 Bytes
Versions: 11
Compression:
Stored size: 632 Bytes
Contents
class SCSSBeautifier::Formatters::DeclarationOrder < Sass::Tree::Visitors::Base # TODO: Account for if/else blocks and include blocks NODE_ORDER = ["ExtendNode", "MixinNode", "PropNode", "RuleNode"] def visit_rule(node) order_children(node) visit_children(node) end def order_children(node) node_hash = Hash.new { |h, k| h[k] = [] } node.children.each do |child| hash_key = child.class.to_s.split("::").last node_hash[hash_key] << child end compiled_array = NODE_ORDER.reduce([]) do |memo, key| memo.concat(node_hash[key]) end node.children = compiled_array end end
Version data entries
11 entries across 11 versions & 1 rubygems