I would like to have my Sinatra app include a view specific stylesheet in the layout.
Consider this simple app:
app_folder_root/
| my_app/
|   my_app.rb
| public/
|   css/
|     index.css
|     layout.css
| views/
|   index.haml
|   layout.haml
config.ru
config.ru:
require 'rubygems'
require './my_app/my_app'
map '/' do
  run MyApp
end
app.rb:
require 'sinatra/base'
class MyApp < Sinatra::Base
  get '/' do
    haml :index
  end
end
I tried setting a variable in my_app.rb that sets the name of the view and tried to reference it in layout.haml, but that did not work (I probably wouldn't have went with this as a final solution to the problem since I felt this was a code smell, but was just trying different possibilities).
This is using Haml, but I am hoping that is irrelevant - thinking it should be the same for erb, etc.
In layout.haml, I would like to reference the view that will be rendered and include a view specific stylesheet by a naming convention. For example, if index.haml is going to render, I would like to include css/index.css. What is the best way to go about doing this?