Sha256: 6eedd4a2c12f1096615853c266e748d696e566082d0e56de1f420bd234fb5043

Contents?: true

Size: 1.42 KB

Versions: 17

Compression:

Stored size: 1.42 KB

Contents

module Sass::Tree
  class DirectiveNode < Node
    attr_accessor :value

    def initialize(value)
      @value = value
      super()
    end

    def to_s(tabs)
      if children.empty?
        value + ";"
      else
        result = if style == :compressed
                   "#{value}{"
                 else
                   "#{'  ' * (tabs - 1)}#{value} {" + (style == :compact ? ' ' : "\n")
                 end
        was_attr = false
        first = true
        children.each do |child|
          next if child.invisible?
          if style == :compact
            if child.is_a?(AttrNode)
              result << "#{child.to_s(first || was_attr ? 1 : tabs + 1)} "
            else
              if was_attr
                result[-1] = "\n"
              end
              rendered = child.to_s(tabs + 1)
              rendered.lstrip! if first
              result << rendered
            end
            was_attr = child.is_a?(AttrNode)
            first = false
          elsif style == :compressed
            result << (was_attr ? ";#{child.to_s(1)}" : child.to_s(1))
            was_attr = child.is_a?(AttrNode)
          else
            result << child.to_s(tabs + 1) + "\n"
          end
        end
        result.rstrip + if style == :compressed
                          "}"
                        else
                          (style == :expanded ? "\n" : " ") + "}\n"
                        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
gohanlonllc-haml-2.1.0.20080513000000 lib/sass/tree/directive_node.rb
gohanlonllc-haml-2.1.0 lib/sass/tree/directive_node.rb
haml-edge-2.1.11 lib/sass/tree/directive_node.rb
haml-edge-2.1.12 lib/sass/tree/directive_node.rb
haml-edge-2.1.10 lib/sass/tree/directive_node.rb
haml-edge-2.1.14 lib/sass/tree/directive_node.rb
haml-edge-2.1.15 lib/sass/tree/directive_node.rb
haml-edge-2.1.16 lib/sass/tree/directive_node.rb
haml-edge-2.1.17 lib/sass/tree/directive_node.rb
haml-edge-2.1.18 lib/sass/tree/directive_node.rb
haml-edge-2.1.19 lib/sass/tree/directive_node.rb
haml-edge-2.1.20 lib/sass/tree/directive_node.rb
haml-edge-2.1.21 lib/sass/tree/directive_node.rb
haml-edge-2.1.13 lib/sass/tree/directive_node.rb
haml-edge-2.1.8 lib/sass/tree/directive_node.rb
haml-edge-2.1.9 lib/sass/tree/directive_node.rb
haml-edge-2.1.7 lib/sass/tree/directive_node.rb