Skip to content
Browse files

Only display the sidebar if it has some content

If we don't have content_for :index_items, then we can assume, we are not on a
guide page (e.g. we are on Credits we don't need a Chapters sidebar).

In addition to this, we let each page to provide content_for :sidebar in case
there is a need to provide custom content (e.g. in the index page, have some
special items on the sidebar).

If we don't have content_for either :index_items or :sidebar, we hide the
sidebar.
  • Loading branch information...
1 parent e6e3101 commit 75bf6940f5d3affafaad3d24a1b61710fbd4588c Daniel Martin committed Oct 23, 2011
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/guides/templates/source/layout.html.erb
View
10 lib/guides/templates/source/layout.html.erb
@@ -54,12 +54,20 @@
<h2><%= Guides.meta["title"] %></h2>
<p><%= Guides.meta["description"] %></p>
<% end %>
+ <% if index_items = yield(:index_items).presence %>
<div id="subCol">
<h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />Chapters</h3>
<ol class="chapters">
- <%= yield(:index_items) %>
+ <%= index_items %>
</ol>
</div>
+ <% else %>
+ <% if sidebar = yield(:sidebar).presence %>
+ <div id="subCol">
+ <%= sidebar %>
+ </div>
+ <% end %>
+ <% end %>
</div>
</div>

0 comments on commit 75bf694

Please sign in to comment.
Something went wrong with that request. Please try again.