Class Sass::Tree::RootNode
In: lib/sass/tree/root_node.rb
Parent: Node
Haml::Util Engine Color SyntaxError UnitConversionError StandardError AbstractSequence CommaSequence Sequence SimpleSequence Simple Parent Universal Class SelectorPseudoClass Id Pseudo Attribute Interpolation Element Node Operation Literal UnaryOperation StringInterpolation Funcall Interpolation Variable Lexer CssLexer Number Bool String Parser Parser CssParser EvaluationContext SassParser StaticParser CssParser Node DebugNode IfNode CommentNode ForNode PropNode MixinNode DirectiveNode VariableNode RootNode ExtendNode WarnNode WhileNode RuleNode MixinDefNode Enumerable ImportNode Merb::BootLoader MerbBootLoader Repl CSS Environment Rack StalenessChecker lib/sass/repl.rb lib/sass/css.rb lib/sass/environment.rb lib/sass/error.rb lib/sass/engine.rb lib/sass/selector/simple_sequence.rb lib/sass/selector/abstract_sequence.rb lib/sass/selector/sequence.rb lib/sass/selector/comma_sequence.rb lib/sass/selector/simple.rb lib/sass/selector.rb Selector lib/sass/script/css_parser.rb lib/sass/script/lexer.rb lib/sass/script/color.rb lib/sass/script/string.rb lib/sass/script/unary_operation.rb lib/sass/script/variable.rb lib/sass/script/funcall.rb lib/sass/script/string_interpolation.rb lib/sass/script/operation.rb lib/sass/script/bool.rb lib/sass/script/parser.rb lib/sass/script/node.rb lib/sass/script/literal.rb lib/sass/script/interpolation.rb lib/sass/script/css_lexer.rb lib/sass/script/number.rb lib/sass/script/functions.rb Functions Script lib/sass/scss/sass_parser.rb lib/sass/scss/static_parser.rb lib/sass/scss/parser.rb lib/sass/scss/css_parser.rb ScriptLexer ScriptParser RX SCSS Files Callbacks lib/sass/tree/while_node.rb lib/sass/tree/if_node.rb lib/sass/tree/mixin_def_node.rb lib/sass/tree/debug_node.rb lib/sass/tree/root_node.rb lib/sass/tree/for_node.rb lib/sass/tree/import_node.rb lib/sass/tree/prop_node.rb lib/sass/tree/node.rb lib/sass/tree/comment_node.rb lib/sass/tree/extend_node.rb lib/sass/tree/mixin_node.rb lib/sass/tree/warn_node.rb lib/sass/tree/directive_node.rb lib/sass/tree/rule_node.rb lib/sass/tree/variable_node.rb Tree lib/sass/plugin/rack.rb lib/sass/plugin/staleness_checker.rb lib/sass/plugin/merb.rb Plugin Sass dot/m_63_0.png

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

Methods

_to_s   cssize   invalid_child?   new   perform   perform!   render   to_s   to_sass   to_scss   to_src  

Attributes

template  [R]  The Sass template from which this node was created

@param template [String]

Public Class methods

@param template [String] The Sass template from which this node was created

[Source]

    # File lib/sass/tree/root_node.rb, line 11
11:       def initialize(template)
12:         super()
13:         @template = template
14:       end

Public Instance methods

Like {Node#cssize}, except that this method will create its own `extends` map if necessary, and it returns that map along with the cssized tree.

@return [(Tree::Node, Haml::Util::SubsetMap)] The resulting tree of static nodes

  *and* the extensions defined for this tree

[Source]

    # File lib/sass/tree/root_node.rb, line 49
49:       def cssize(extends = Haml::Util::SubsetMap.new, parent = nil)
50:         return super(extends), extends
51:       rescue Sass::SyntaxError => e
52:         e.sass_template = @template
53:         raise e
54:       end

@see Node#perform

[Source]

    # File lib/sass/tree/root_node.rb, line 35
35:       def perform(environment)
36:         environment.options = @options if environment.options.nil? || environment.options.empty?
37:         super
38:       rescue Sass::SyntaxError => e
39:         e.sass_template = @template
40:         raise e
41:       end

@see \{Node#perform!}

[Source]

    # File lib/sass/tree/root_node.rb, line 57
57:       def perform!(environment)
58:         environment.options = @options if environment.options.nil? || environment.options.empty?
59:         super
60:       end

Runs the dynamic Sass code and computes the CSS for the tree.

@see perform @see to_s

[Source]

    # File lib/sass/tree/root_node.rb, line 28
28:       def render
29:         result, extends = perform(Environment.new).cssize
30:         result = result.do_extend(extends) unless extends.empty?
31:         result.to_s
32:       end

@see Node#to_s

[Source]

    # File lib/sass/tree/root_node.rb, line 17
17:       def to_s(*args)
18:         super
19:       rescue Sass::SyntaxError => e
20:         e.sass_template = @template
21:         raise e
22:       end

Converts a node to Sass code that will generate it.

@param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize}) @return [String] The Sass code corresponding to the node

[Source]

    # File lib/sass/tree/root_node.rb, line 66
66:       def to_sass(opts = {})
67:         to_src(opts, :sass)
68:       end

Converts a node to SCSS code that will generate it.

@param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize}) @return [String] The SCSS code corresponding to the node

[Source]

    # File lib/sass/tree/root_node.rb, line 74
74:       def to_scss(opts = {})
75:         to_src(opts, :scss)
76:       end

Protected Instance methods

Computes the CSS corresponding to this Sass tree.

@param args [Array] ignored @return [String] The resulting CSS @see Sass::Tree

[Source]

     # File lib/sass/tree/root_node.rb, line 100
100:       def _to_s(*args)
101:         result = String.new
102:         children.each do |child|
103:           next if child.invisible?
104:           child_str = child.to_s(1)
105:           result << child_str + (style == :compressed ? '' : "\n")
106:         end
107:         result.rstrip!
108:         return "" if result.empty?
109:         return result + "\n"
110:       end

Returns an error message if the given child node is invalid, and false otherwise.

Only property nodes are invalid at root level.

@see Node#invalid_child?

[Source]

     # File lib/sass/tree/root_node.rb, line 118
118:       def invalid_child?(child)
119:         return unless child.is_a?(Tree::PropNode)
120:         "Properties aren't allowed at the root of a document." +
121:           child.pseudo_class_selector_message
122:       end

@see Node#to_src

[Source]

    # File lib/sass/tree/root_node.rb, line 81
81:       def to_src(opts, fmt)
82:         Haml::Util.enum_cons(children + [nil], 2).map do |child, nxt|
83:           child.send("to_#{fmt}", 0, opts) +
84:             if nxt &&
85:                 (child.is_a?(CommentNode) && child.line + child.value.count("\n") + 1 == nxt.line) ||
86:                 (child.is_a?(ImportNode) && nxt.is_a?(ImportNode) && child.line + 1 == nxt.line) ||
87:                 (child.is_a?(VariableNode) && nxt.is_a?(VariableNode) && child.line + 1 == nxt.line)
88:               ""
89:             else
90:               "\n"
91:             end
92:         end.join.rstrip + "\n"
93:       end

[Validate]