Sunday, 18 August 2013

How to set a custom directory for layouts in Sinatra?

How to set a custom directory for layouts in Sinatra?

I have a Sinatra app with multiple layouts. I want to isolate them into
their own subdirectory in views:
app.rb
views/
views/layouts/
views/layouts/default.haml
views/layouts/print.haml
views/layouts/mobile.haml
This works, except that I have to explicitly set a layout with each render
call:
get '/' do
haml :index, {:layout => :'layouts/default'}
end
Is there a way to set the layout globally (for all routes within a module,
for example), or to tell Sinatra where look for layouts outside of default
directory?

No comments:

Post a Comment