Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Only display the sidebar if it has some content #12

Merged
merged 1 commit into from

2 participants

@etdsoft

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.

Daniel Martin 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.
75bf694
@wagenet wagenet merged commit 6bdb5a8 into wycats:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 23, 2011
  1. Only display the sidebar if it has some content

    Daniel Martin authored
    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.
This page is out of date. Refresh to see the latest.
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>
Something went wrong with that request. Please try again.