Class Sass::Tree::DirectiveNode
In: lib/sass/tree/directive_node.rb
Parent: Node
Haml::Util Engine Color SyntaxError UnitConversionError StandardError AbstractSequence CommaSequence Sequence SimpleSequence Simple Parent Universal Class Negation Id Pseudo Attribute Interpolation Element Node Operation Literal UnaryOperation StringInterpolation Funcall Variable Interpolation Lexer CssLexer Number String Bool Parser Parser CssParser EvaluationContext StaticParser SassParser CssParser Node DebugNode IfNode CommentNode ForNode PropNode MixinNode DirectiveNode VariableNode RootNode WarnNode ExtendNode RuleNode MixinDefNode WhileNode 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 ScriptParser ScriptLexer 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_61_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

_to_s   new   to_src  

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

Protected 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 36
36:     def _to_s(tabs)
37:       return value + ";" unless has_children
38:       return value + " {}" if children.empty?
39:       result = if style == :compressed
40:                  "#{value}{"
41:                else
42:                  "#{'  ' * (tabs - 1)}#{value} {" + (style == :compact ? ' ' : "\n")
43:                end
44:       was_prop = false
45:       first = true
46:       children.each do |child|
47:         next if child.invisible?
48:         if style == :compact
49:           if child.is_a?(PropNode)
50:             result << "#{child.to_s(first || was_prop ? 1 : tabs + 1)} "
51:           else
52:             if was_prop
53:               result[-1] = "\n"
54:             end
55:             rendered = child.to_s(tabs + 1).dup
56:             rendered = rendered.lstrip if first
57:             result << rendered.rstrip + "\n"
58:           end
59:           was_prop = child.is_a?(PropNode)
60:           first = false
61:         elsif style == :compressed
62:           result << (was_prop ? ";#{child.to_s(1)}" : child.to_s(1))
63:           was_prop = child.is_a?(PropNode)
64:         else
65:           result << child.to_s(tabs + 1) + "\n"
66:         end
67:       end
68:       result.rstrip + if style == :compressed
69:                         "}"
70:                       else
71:                         (style == :expanded ? "\n" : " ") + "}\n"
72:                       end
73:     end

@see Node#to_src

[Source]

    # File lib/sass/tree/directive_node.rb, line 26
26:     def to_src(tabs, opts, fmt)
27:       res = "#{'  ' * tabs}#{value}"
28:       return res + "#{semi fmt}\n" unless has_children
29:       res + children_to_src(tabs, opts, fmt) + "\n"
30:     end

[Validate]