class Sass::CSS

def flatten_rule(rule)

Other tags:
    See: #flatten_rules -

Parameters:
  • rule (Tree::RuleNode) -- The candidate for flattening
def flatten_rule(rule)
  while rule.children.size == 1 && rule.children.first.is_a?(Tree::RuleNode)
    child = rule.children.first
    if child.rules.first[0] == ?&
      rule.rules = [child.rules.first.gsub(/^&/, rule.rules.first)]
    else
      rule.rules = ["#{rule.rules.first} #{child.rules.first}"]
    end
    rule.children = child.children
  end
  flatten_rules(rule)
end