How not to include layout.haml in sinatra app

I have a ruby ​​sinatra application that uses haml. I use layout.haml for the general menu on all pages. Say I have login.haml, main.haml and reports.haml. I just want to use layout.haml for login.haml and main.haml. How can I exclude layout.haml from report.haml? thanks

+4
source share
1 answer

Two (and several) ways:

Global

class MyApp < Sinatra::Base set :haml, :layout => false get '/reports' do haml :reports end end 

Blacklisting

If the number of routes that do not require layouts is less, then this is the template:

 class MyApp < Sinatra::Base get '/reports' do haml :reports, :layout => false end end 

Whitelisting

If routes that don't need a layout.haml file layout.haml longer, however, Sinatra does not seem to support overriding the global declaration set :haml, :layout => false . I took the liberty of opening the issue for this function, since it seems reasonable enough (I hope you will not mind).

+7
source

Source: https://habr.com/ru/post/1486160/


All Articles