Sha256: a85e533f723c71ee98e0bea6e0996c50892c4f9a7ab848972070a68ba62542aa

Contents?: true

Size: 1.56 KB

Versions: 23

Compression:

Stored size: 1.56 KB

Contents

module Sass
  module Tree
    # A static node that is the root node of the Sass document.
    class RootNode < Node
      # The Sass template from which this node was created
      #
      # @param template [String]
      attr_reader :template

      # @param template [String] The Sass template from which this node was created
      def initialize(template)
        super()
        @template = template
      end

      # @see \{Node#to\_s}
      def to_s(*args)
        super
      rescue Sass::SyntaxError => e
        e.sass_template = @template
        raise e
      end

      # @see \{Node#perform}
      def perform(*args)
        super
      rescue Sass::SyntaxError => e
        e.sass_template = @template
        raise e
      end

      protected

      # Computes the CSS corresponding to this Sass tree.
      #
      # @param args [Array] ignored
      # @return [String] The resulting CSS
      # @raise [Sass::SyntaxError] if some element of the tree is invalid
      # @see Sass::Tree
      def _to_s(*args)
        result = String.new
        children.each do |child|
          if child.is_a? PropNode
            message = "Properties aren't allowed at the root of a document." +
              child.pseudo_class_selector_message
            raise Sass::SyntaxError.new(message, :line => child.line)
          end

          next if child.invisible?
          child_str = child.to_s(1)
          result << child_str + (style == :compressed ? '' : "\n")
        end
        result.rstrip!
        return "" if result.empty?
        return result + "\n"
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
haml-edge-2.3.87 lib/sass/tree/root_node.rb
haml-edge-2.3.88 lib/sass/tree/root_node.rb
haml-edge-2.3.86 lib/sass/tree/root_node.rb
haml-edge-2.3.85 lib/sass/tree/root_node.rb
haml-edge-2.3.84 lib/sass/tree/root_node.rb
haml-edge-2.3.83 lib/sass/tree/root_node.rb
haml-edge-2.3.82 lib/sass/tree/root_node.rb
haml-edge-2.3.81 lib/sass/tree/root_node.rb
haml-edge-2.3.80 lib/sass/tree/root_node.rb
haml-edge-2.3.79 lib/sass/tree/root_node.rb
haml-edge-2.3.78 lib/sass/tree/root_node.rb
haml-edge-2.3.77 lib/sass/tree/root_node.rb
haml-edge-2.3.76 lib/sass/tree/root_node.rb
haml-edge-2.3.75 lib/sass/tree/root_node.rb
haml-edge-2.3.74 lib/sass/tree/root_node.rb
haml-edge-2.3.73 lib/sass/tree/root_node.rb
haml-edge-2.3.72 lib/sass/tree/root_node.rb
haml-edge-2.3.71 lib/sass/tree/root_node.rb
haml-edge-2.3.70 lib/sass/tree/root_node.rb
haml-edge-2.3.69 lib/sass/tree/root_node.rb