Class Sass::Tree::DirectiveNode
In: lib/sass/css.rb
lib/sass/tree/directive_node.rb
Parent: Object
Haml::Util Engine Color SyntaxError UnitConversionError StandardError Node Operation Literal UnaryOperation Funcall Variable Number String Bool EvaluationContext Node\n[lib/sass/css.rb\nlib/sass/tree/node.rb] DebugNode IfNode CommentNode ForNode MixinNode VariableNode ImportNode WhileNode MixinDefNode Repl CSS Environment Lexer Parser PropNode\n[lib/sass/css.rb\nlib/sass/tree/prop_node.rb] DirectiveNode\n[lib/sass/css.rb\nlib/sass/tree/directive_node.rb] RuleNode\n[lib/sass/css.rb\nlib/sass/tree/rule_node.rb] Rack lib/sass/repl.rb lib/sass/css.rb lib/sass/environment.rb lib/sass/error.rb lib/sass/engine.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/operation.rb lib/sass/script/bool.rb lib/sass/script/parser.rb lib/sass/script/literal.rb lib/sass/script/node.rb lib/sass/script/number.rb lib/sass/script/functions.rb Functions Script Files 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/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/mixin_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 Plugin Sass dot/m_54_0.png

A static node representing an unproccessed Sass `@`-directive. Directives known to Sass, like `@for` and `@debug`, are handled by their own nodes; only CSS directives like `@media` and `@font-face` become {DirectiveNode}s.

`@import` is a bit of a weird case; it becomes an {ImportNode}.

@see Sass::Tree

Methods

new   to_s   to_sass  

Attributes

value  [RW]  The text of the directive, `@` and all.

@return [String]

Public Class methods

@param value [String] See \{value}

[Source]

    # File lib/sass/tree/directive_node.rb, line 18
18:     def initialize(value)
19:       @value = value
20:       super()
21:     end

Public Instance methods

Computes the CSS for the directive.

@param tabs [Fixnum] The level of indentation for the CSS @return [String] The resulting CSS

[Source]

    # File lib/sass/tree/directive_node.rb, line 27
27:     def to_s(tabs)
28:       if children.empty?
29:         value + ";"
30:       else
31:         result = if style == :compressed
32:                    "#{value}{"
33:                  else
34:                    "#{'  ' * (tabs - 1)}#{value} {" + (style == :compact ? ' ' : "\n")
35:                  end
36:         was_prop = false
37:         first = true
38:         children.each do |child|
39:           next if child.invisible?
40:           if style == :compact
41:             if child.is_a?(PropNode)
42:               result << "#{child.to_s(first || was_prop ? 1 : tabs + 1)} "
43:             else
44:               if was_prop
45:                 result[-1] = "\n"
46:               end
47:               rendered = child.to_s(tabs + 1)
48:               rendered.lstrip! if first
49:               result << rendered
50:             end
51:             was_prop = child.is_a?(PropNode)
52:             first = false
53:           elsif style == :compressed
54:             result << (was_prop ? ";#{child.to_s(1)}" : child.to_s(1))
55:             was_prop = child.is_a?(PropNode)
56:           else
57:             result << child.to_s(tabs + 1) + "\n"
58:           end
59:         end
60:         result.rstrip + if style == :compressed
61:                           "}"
62:                         else
63:                           (style == :expanded ? "\n" : " ") + "}\n"
64:                         end
65:       end
66:     end

@see Node#to_sass

[Source]

    # File lib/sass/css.rb, line 48
48:       def to_sass(tabs, opts = {})
49:         "#{'  ' * tabs}#{value}#{children.map {|c| c.to_sass(tabs + 1, opts)}}\n"
50:       end

[Validate]