Class: Sass::Tree::AttrNode
- Defined in:
- lib/gems/haml-2.0.4/lib/sass/css.rb,
lib/gems/haml-2.0.4/lib/sass/tree/attr_node.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Attributes inherited from ValueNode
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(name, value, style) ⇒ AttrNode
constructor
A new instance of AttrNode.
- #to_s(tabs, parent_name = nil) ⇒ Object
- #to_sass(tabs, opts = {}) ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(name, value, style) ⇒ AttrNode
Returns a new instance of AttrNode.
7 8 9 10 |
# File 'lib/gems/haml-2.0.4/lib/sass/tree/attr_node.rb', line 7 def initialize(name, value, style) @name = name super(value, style) end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/gems/haml-2.0.4/lib/sass/tree/attr_node.rb', line 5 def name @name end |
Instance Method Details
#to_s(tabs, parent_name = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gems/haml-2.0.4/lib/sass/tree/attr_node.rb', line 12 def to_s(tabs, parent_name = nil) if value[-1] == ?; raise Sass::SyntaxError.new("Invalid attribute: #{declaration.dump} (This isn't CSS!).", @line) end real_name = name real_name = "#{parent_name}-#{real_name}" if parent_name if value.empty? && children.empty? raise Sass::SyntaxError.new("Invalid attribute: #{declaration.dump}.", @line) end join_string = case @style when :compact; ' ' when :compressed; '' else "\n" end spaces = ' ' * (tabs - 1) to_return = '' if !value.empty? to_return << "#{spaces}#{real_name}:#{@style == :compressed ? '' : ' '}#{value};#{join_string}" end children.each do |kid| to_return << "#{kid.to_s(tabs, real_name)}" << join_string end (@style == :compressed && parent_name) ? to_return : to_return[0...-1] end |
#to_sass(tabs, opts = {}) ⇒ Object
39 40 41 |
# File 'lib/gems/haml-2.0.4/lib/sass/css.rb', line 39 def to_sass(tabs, opts = {}) "#{' ' * tabs}#{opts[:alternate] ? '' : ':'}#{name}#{opts[:alternate] ? ':' : ''} #{value}\n" end |