Class: HamlInterceptor

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

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}) ⇒ HamlInterceptor

Returns a new instance of HamlInterceptor.



4
5
6
# File 'lib/haml_interceptor.rb', line 4

def initialize(app, opts={})
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/haml_interceptor.rb', line 8

def call(env)
  status, headers, body = @app.call(env)
  if headers.has_key?('Content-Type') && headers['Content-Type'] =~ /javascript/
    body = Haml::HTML.new(body.body.join).render
  end
  [status, headers, body]
end