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?
Need to RTFM better... So there is no specific option for Sinatra itself, but you can set a default layout for each rendering engine, e.g. HAML:
configure do
set :haml, :layout => :'layouts/default'
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With