class Sass::Tree::Visitors::ToCss

def visit_directive(node)

def visit_directive(node)
  was_in_directive = @in_directive
  tab_str = '  ' * @tabs
  if !node.has_children || node.children.empty?
    output(tab_str)
    for_node(node) {output(node.resolved_value)}
    if node.has_children
      output("#{' ' unless node.style == :compressed}{}")
    elsif node.children.empty?
      output(";")
    end
    return
  end
  @in_directive ||= !node.is_a?(Sass::Tree::MediaNode)
  output(tab_str) if node.style != :compressed
  for_node(node) {output(node.resolved_value)}
  output(node.style == :compressed ? "{" : " {")
  output(node.style == :compact ? ' ' : "\n") if node.style != :compressed
  had_children = true
  first = true
  node.children.each do |child|
    next if child.invisible?
    if node.style == :compact
      if child.is_a?(Sass::Tree::PropNode)
        with_tabs(first || !had_children ? 0 : @tabs + 1) do
          visit(child)
          output(' ')
        end
      else
        unless had_children
          erase! 1
          output "\n"
        end
        if first
          lstrip {with_tabs(@tabs + 1) {visit(child)}}
        else
          with_tabs(@tabs + 1) {visit(child)}
        end
        rstrip!
        output "\n"
      end
      had_children = child.has_children
      first = false
    elsif node.style == :compressed
      unless had_children
        output(";") unless trailing_semicolon?
      end
      with_tabs(0) {visit(child)}
      had_children = child.has_children
    else
      with_tabs(@tabs + 1) {visit(child)}
      output "\n"
    end
  end
  rstrip!
  if node.style == :compressed && trailing_semicolon?
    erase! 1
  end
  if node.style == :expanded
    output("\n#{tab_str}")
  elsif node.style != :compressed
    output(" ")
  end
  output("}")
ensure
  @in_directive = was_in_directive
end