Class: Nokogiri::XML::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/html2slim/nokogiri_monkeypatches.rb

Instance Method Summary collapse

Instance Method Details

#to_slim(lvl = 0) ⇒ Object



4
5
6
7
8
9
# File 'lib/html2slim/nokogiri_monkeypatches.rb', line 4

def to_slim(lvl = 0)
  str = escape(content)
  return nil if str.strip.empty?

  ('  ' * lvl) + %(| #{str.gsub(/\s+/, ' ')})
end