Class | Sass::Tree::DirectiveNode
In: | lib/sass/tree/directive_node.rb
Parent: | Node

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

new(value)

@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

_to_s(tabs)

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

to_src(tabs, opts, fmt)

@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]