Module Haml::HTML::Node
In: lib/haml/html.rb

A module containing utility methods that every Hpricot node should have.

Methods

Public Instance methods

Returns the Haml representation of the given node.

@param tabs [Fixnum] The indentation level of the resulting Haml. @option options (see Haml::HTML#initialize)

[Source]

    # File lib/haml/html.rb, line 16
16:       def to_haml(tabs, options)
17:         parse_text(self.to_s, tabs)
18:       end

Private Instance methods

[Source]

    # File lib/haml/html.rb, line 26
26:       def attr_hash
27:         attributes.to_hash
28:       end

[Source]

    # File lib/haml/html.rb, line 30
30:       def parse_text(text, tabs)
31:         text.strip!
32:         text.gsub!('#{', '\#{') #'
33:         if text.empty?
34:           String.new
35:         else
36:           lines = text.split("\n")
37: 
38:           lines.map do |line|
39:             line.strip!
40:             "#{tabulate(tabs)}#{'\\' if Haml::Engine::SPECIAL_CHARACTERS.include?(line[0])}#{line}\n"
41:           end.join
42:         end
43:       end

[Source]

    # File lib/haml/html.rb, line 22
22:       def tabulate(tabs)
23:         '  ' * tabs
24:       end

[Validate]