Class: Sass::Tree::AttrNode

Class | Sass::Tree::AttrNode
In: | lib/sass/tree/attr_node.rb
Parent: | ValueNode

### Methods

new to_s

### Attributes

name | [RW] |

### Public Class methods

new(name, value, style)

[Source]

        # File lib/sass/tree/attr_node.rb, line 7
     7:     def initialize(name, value, style)
     8:       @name = name
     9:       super(value, style)
    10:     end

### Public Instance methods

to_s(tabs, parent_name = nil)

[Source]

        # File lib/sass/tree/attr_node.rb, line 12
    12:     def to_s(tabs, parent_name = nil)
    13:       if value[-1] == ?;
    14:         raise Sass::SyntaxError.new("Invalid attribute: #{declaration.dump} (This isn't CSS!).", @line)
    15:       end
    16:       real_name = name
    17:       real_name = "#{parent_name}-#{real_name}" if parent_name
    18:
    19:       if value.empty? && children.empty?
    20:         raise Sass::SyntaxError.new("Invalid attribute: #{declaration.dump}.", @line)
    21:       end
    22:
    23:       join_string = case @style
    24:                     when :compact; ' '
    25:                     when :compressed; ''
    26:                     else "\n"
    27:                     end
    28:       spaces = '  ' * (tabs - 1)
    29:       to_return = ''
    30:       if !value.empty?
    31:         to_return << "#{spaces}#{real_name}:#{@style == :compressed ? '' : ' '}#{value};#{join_string}"
    32:       end
    33:
    34:       children.each do |kid|
    35:         to_return << "#{kid.to_s(tabs, real_name)}" << join_string
    36:       end
    37:
    38:       (@style == :compressed && parent_name) ? to_return : to_return[0...-1]
    39:     end

[Validate]