Class: Nitro::Squeeze
- Inherits:
-
Object
- Object
- Nitro::Squeeze
- Defined in:
- lib/nitro/compiler/squeeze.rb
Overview
A compiler transformation pipeline stage that compresses the generated xhtml code.
Class Method Summary collapse
-
.transform(text, compiler = nil) ⇒ Object
Compresses the inline xhtml.
Class Method Details
.transform(text, compiler = nil) ⇒ Object
Compresses the inline xhtml. Does not touch the ruby code.
10 11 12 13 14 15 |
# File 'lib/nitro/compiler/squeeze.rb', line 10 def self.transform(text, compiler = nil) return text.gsub(/\@out \<\< \%\^(.*?)\^/m) do |match| c = $1.gsub(/^(\s*)/m, '').squeeze(" \t").tr("\n", '').tr("\t", ' ') "@out << %{#{c}}" end end |