Class: Ki::Middleware::SassCompiler
- Inherits:
-
Object
- Object
- Ki::Middleware::SassCompiler
- Includes:
- BaseMiddleware
- Defined in:
- lib/ki/middleware/sass_compiler.rb
Instance Method Summary collapse
Methods included from BaseMiddleware
Instance Method Details
#call(env) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ki/middleware/sass_compiler.rb', line 6 def call(env) req = BaseRequest.new env sass_path = req.path.to_s[0...-4] + '.sass' # if req ends with css and it does not exist, if a sass file exists instead if !public_file_exists?(req) && format_of(req) == 'css' && public_file_exists?(sass_path) eng = Sass::Engine.new(File.read(public_file_path(sass_path)), syntax: :sass) Rack::Response.new(eng.render, 200, { 'Content-Type' => 'text/css' }).finish else @app.call env end end |