Class: Hpricot::Elem

Inherits:
Object show all
Defined in:
lib/haml/html.rb

Overview

See Also:

Instance Method Summary collapse

Instance Method Details

#to_haml(tabs, options) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/haml/html.rb', line 170

def to_haml(tabs, options)
  output = "#{tabulate(tabs)}"
  if options[:rhtml] && name[0...5] == 'haml:'
    return output + send("haml_tag_#{name[5..-1]}", CGI.unescapeHTML(self.inner_text))
  end

  output += "%#{name}" unless name == 'div' &&
    (static_id?(options) || static_classname?(options))

  if attributes
    if static_id?(options)
      output += "##{attributes['id']}"
      remove_attribute('id')
    end
    if static_classname?(options)
      attributes['class'].split(' ').each { |c| output += ".#{c}" }
      remove_attribute('class')
    end
    output += haml_attributes(options) if attributes.length > 0
  end

  (self.children || []).inject(output + "\n") do |output, child|
    output + child.to_haml(tabs + 1, options)
  end
end