37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/html2slim/hpricot_monkeypatches.rb', line 37
def slim(lvl=0)
r = (' ' * lvl)
if self.name == 'div' and (self.has_attribute?('id') || self.has_attribute?('class'))
r += ''
else
r += self.name
end
if(self.has_attribute?('id'))
r += "##{self['id']}"
self.remove_attribute('id')
end
if(self.has_attribute?('class'))
r += ".#{self['class'].split(/\s+/).join('.')}"
self.remove_attribute('class')
end
unless attributes_as_html.to_s.strip.empty?
r += "[#{attributes_as_html.to_s.strip}]"
end
r
end
|