class Sass::Tree::RootNode

A static node that is the root node of the Sass document.

def _to_s(*args)

Other tags:
    See: Sass::Tree -

Returns:
  • (String) - The resulting CSS

Parameters:
  • args (Array) -- ignored
def _to_s(*args)
  result = String.new
  children.each do |child|
    next if child.invisible?
    child_str = child.to_s(1)
    result << child_str + (style == :compressed ? '' : "\n")
  end
  result.rstrip!
  return "" if result.empty?
  result << "\n"
  unless Haml::Util.ruby1_8? || result.ascii_only?
    if children.first.is_a?(CharsetNode)
      begin
        encoding = children.first.name
        # Default to big-endian encoding, because we have to decide somehow
        encoding << 'BE' if encoding =~ /\Autf-(16|32)\Z/i
        result = result.encode(Encoding.find(encoding))
      rescue EncodingError
      end
    end
    result = "@charset \"#{result.encoding.name}\";#{
      style == :compressed ? '' : "\n"
    }".encode(result.encoding) + result
  end
  result
end

def cssize(extends = Haml::Util::SubsetMap.new, parent = nil)

Returns:
  • ((Tree::Node, Haml::Util::SubsetMap)) - The resulting tree of static nodes
def cssize(extends = Haml::Util::SubsetMap.new, parent = nil)
  return super(extends, parent), extends
rescue Sass::SyntaxError => e
  e.sass_template ||= @template
  raise e
end

def cssize!(extends, parent)

Other tags:
    See: Node#cssize -
def cssize!(extends, parent)
  super
  # In Ruby 1.9 we can make all @charset nodes invisible
  # and infer the final @charset from the encoding of the final string.
  if Haml::Util.ruby1_8? && parent.nil?
    charset = self.children.find {|c| c.is_a?(CharsetNode)}
    self.children.reject! {|c| c.is_a?(CharsetNode)}
    self.children.unshift charset if charset
  end
end

def initialize(template)

Parameters:
  • template (String) -- The Sass template from which this node was created
def initialize(template)
  super()
  @template = template
end

def invalid_child?(child)

Other tags:
    See: Node#invalid_child? -
def invalid_child?(child)
  case child
  when Tree::ExtendNode
    "Extend directives may only be used within rules."
  when Tree::PropNode
    "Properties aren't allowed at the root of a document." +
      child.pseudo_class_selector_message
  else
    return
  end
end

def perform(environment)

Other tags:
    See: Node#perform -
def perform(environment)
  environment.options = @options if environment.options.nil? || environment.options.empty?
  super
rescue Sass::SyntaxError => e
  e.sass_template ||= @template
  raise e
end

def perform!(environment)

Other tags:
    See: \{Node#perform!} -
def perform!(environment)
  environment.options = @options if environment.options.nil? || environment.options.empty?
  super
end

def render

Other tags:
    See: #to_s -
    See: #perform -
def render
  result, extends = perform(Environment.new).cssize
  result = result.do_extend(extends) unless extends.empty?
  result.to_s
end

def to_s(*args)

Other tags:
    See: Node#to_s -
def to_s(*args)
  super
rescue Sass::SyntaxError => e
  e.sass_template ||= @template
  raise e
end

def to_sass(opts = {})

Returns:
  • (String) - The Sass code corresponding to the node

Parameters:
  • opts ({Symbol => Object}) -- An options hash (see {Sass::CSS#initialize})
def to_sass(opts = {})
  to_src(opts, :sass)
end

def to_scss(opts = {})

Returns:
  • (String) - The SCSS code corresponding to the node

Parameters:
  • opts ({Symbol => Object}) -- An options hash (see {Sass::CSS#initialize})
def to_scss(opts = {})
  to_src(opts, :scss)
end

def to_src(opts, fmt)

Other tags:
    See: Node#to_src -
def to_src(opts, fmt)
  Haml::Util.enum_cons(children + [nil], 2).map do |child, nxt|
    child.send("to_#{fmt}", 0, opts) +
      if nxt &&
          (child.is_a?(CommentNode) && child.line + child.value.count("\n") + 1 == nxt.line) ||
          (child.is_a?(ImportNode) && nxt.is_a?(ImportNode) && child.line + 1 == nxt.line) ||
          (child.is_a?(VariableNode) && nxt.is_a?(VariableNode) && child.line + 1 == nxt.line)
        ""
      else
        "\n"
      end
  end.join.rstrip + "\n"
end