I wrote the way to build structured layout in Rails.
You can use it when you want to use the same frame according to the page URLs. For example, to show control bar in admin pages.
I examined in the following environment.
- Rails 3, 4
How to do it?
app/views/layouts/application.html.erb is the layout file. This time, let’s create
app/views/layouts/sub_application.html.haml. In my recent project, I created an layout under another directory, such as
-content_for :content do
here is the top of content
here is the bottom of content
=render templates: 'layouts/application'
According to the Ruby version, you have to write as
render :templates =>'layouts/application'.
:content. And indicate to show
<%= content_for?(:content) ? yield(:content) : yield %>
Like this, the layout template shows show
:content is defined, otherwise it shows