Reputation: 6599
In a sinatra app, We have views/layout.erb
as the top layout. But some pages would share a common look only for a certain channel but also need the globally shared parts in views/layout.erb
. Is there a way to define a nested layout which use views/layout.erb
as its parent layout?
Upvotes: 2
Views: 1650
Reputation: 12906
What might be the easiest way is to have the specific layout also include the global layout, and set that specific layout as the default for the routes you need.
In specific.erb
<%= erb :layout %> # if you are using Sinatra 1.1 and up
<%= erb :layout, :layout => false %> # if you are using Sinatra prior to 1.1
Using a before filter would allow you to set that in one location, if that is possible.
before '/special' do
@default_layout = :specific
end
Otherwise, just use that same line @default_layout = :specific
in your route.
Upvotes: 1