Module: SquashWhitespace

Defined in:
lib/squash_whitespace.rb,
lib/squash_whitespace/helpers.rb,
lib/squash_whitespace/railtie.rb,
lib/squash_whitespace/version.rb

Defined Under Namespace

Modules: Helpers Classes: Railtie

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.squash_html(html, options = {}) ⇒ Object



3
4
5
6
7
# File 'lib/squash_whitespace.rb', line 3

def squash_html(html, options = {})
  html = html.gsub(/\A\s+|\s+\Z/, '').gsub(/>\s+</, '><').gsub(/^\s+</, '<')
  html = html.gsub(/>\s*(.*?)\s*</, '>\1<') if options[:strip]
  html
end