Reputation: 384
I have a base layout in /views/layouts/application.html.haml
%html
%head
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= csrf_meta_tags
%body
= render 'layouts/header'
= yield
= render 'layouts/footer'
In all my views rendered, it inherits from the above with the header and footer.
How can I render a page that doesn't inherit from /views/layouts/application ? Or just render partially by omitting the header and footer, but still include the stylesheet and javascript?
Upvotes: 0
Views: 30
Reputation: 3329
You could render the header and footer for all views except a specific view by checking the controller_name
and action_name
. e.g
%html
%head
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= csrf_meta_tags
%body
= render 'layouts/header' unless controller_name == 'CONTROLLER' && action_name == 'ACTION'
= yield
= render 'layouts/footer' unless controller_name == 'CONTROLLER' && action_name == 'ACTION'
So if you put users
instead of CONTROLLER and show
instead of ACTION the header and footer would not display for the user's show action.
Upvotes: 1