Sha256: f86802028f126d97f13354bd88c87b19c160167359fe764800a373ea61b527ae

Contents?: true

Size: 1.36 KB

Versions: 33

Compression:

Stored size: 1.36 KB

Contents

require 'sass/tree/node'
require 'sass/tree/value_node'

module Sass::Tree
  class DirectiveNode < ValueNode
    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|
          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

33 entries across 33 versions & 5 rubygems

Version Path
radiantcms-couchrest_model-0.2.4 vendor/plugins/haml/lib/sass/tree/directive_node.rb
radiantcms-couchrest_model-0.2.2 vendor/plugins/haml/lib/sass/tree/directive_node.rb
radiantcms-couchrest_model-0.2.1 vendor/plugins/haml/lib/sass/tree/directive_node.rb
radiantcms-couchrest_model-0.2 vendor/plugins/haml/lib/sass/tree/directive_node.rb
radiantcms-couchrest_model-0.1.9 vendor/plugins/haml/lib/sass/tree/directive_node.rb
radiantcms-couchrest_model-0.1.8 vendor/plugins/haml/lib/sass/tree/directive_node.rb
radiantcms-couchrest_model-0.1.7 vendor/plugins/haml/lib/sass/tree/directive_node.rb
radiantcms-couchrest_model-0.1.6 vendor/plugins/haml/lib/sass/tree/directive_node.rb
radiantcms-couchrest_model-0.1.5 vendor/plugins/haml/lib/sass/tree/directive_node.rb
radiant-0.7.2 vendor/plugins/haml/lib/sass/tree/directive_node.rb
radiant-0.8.2 vendor/plugins/haml/lib/sass/tree/directive_node.rb
radiant-rc-0.9.0 vendor/plugins/haml/lib/sass/tree/directive_node.rb
radiant-0.8.1 vendor/plugins/haml/lib/sass/tree/directive_node.rb
haml-2.0.10 lib/sass/tree/directive_node.rb
haml-2.0.8 lib/sass/tree/directive_node.rb
haml-2.0.3 lib/sass/tree/directive_node.rb
haml-2.0.7 lib/sass/tree/directive_node.rb
haml-2.0.5 lib/sass/tree/directive_node.rb
haml-2.0.4 lib/sass/tree/directive_node.rb
haml-2.0.1 lib/sass/tree/directive_node.rb