Skip to content

Instantly share code, notes, and snippets.

@thiagofm
Created July 6, 2012 16:43
Show Gist options
  • Select an option

  • Save thiagofm/3061257 to your computer and use it in GitHub Desktop.

Select an option

Save thiagofm/3061257 to your computer and use it in GitHub Desktop.
Rãby
# antes:
<!--MENU-->
<nav class="menu">
<ul>
<li>
<% if params[:action].eql? 'sobre' %>
<%= link_to 'Sobre', help_sobre_url, :class => 'on' %>
<% else %>
<%= link_to 'Sobre', help_sobre_url %>
<% end%>
</li>
<li>
<% if params[:action].eql? 'time' %>
<%= link_to 'Time', help_time_url, :class => 'on' %>
<% else %>
<%= link_to 'Time', help_time_url %>
<% end%>
</li>
<li>
<% if params[:action].eql? 'extras' %>
<%= link_to 'Extras', help_extras_url, :class => 'on' %>
<% else %>
<%= link_to 'Extras', help_extras_url %>
<% end%>
<li>
<% if params[:action].eql? 'legal' %>
<%= link_to 'Legal', help_legal_url, :class => 'on' %>
<% else %>
<%= link_to 'Legal', help_legal_url %>
<% end %>
</li>
<!--<li><a href="#">Blog</a></li>-->
<li>
<% if params[:action].eql? 'index' %>
<%= link_to 'Ajuda', help_root_path, :class => 'on' %>
<% else %>
<%= link_to 'Ajuda', help_root_path %>
<% end %>
<!--<li><a href="#">Contato</a></li>-->
</ul>
<%= link_to 'ShopCliq', root_path, :class => "logo" %>
</nav>
<!--MENU-->
# depois:
<!--MENU-->
<%= content_tag :nav, :class => 'menu' do %>
<%= content_tag :ul do %>
<% ([{ :action => 'sobre', :link => 'Sobre' },
{ :action => 'time', :link => 'Time' },
{ :action => 'extras', :link => 'Extras' },
{ :action => 'legal', :link => 'Legal' },
{ :action => 'index', :link => 'Ajuda' }]).each do |item| %>
<%= content_tag :li do %>
<% if params[:action] == item[:action] %>
<%= link_to item[:link], eval("help_#{item[:action]}_url"), :class => 'on' %>
<% else %>
<%= link_to item[:link], eval("help_#{item[:action]}_url") %>
<% end %>
<% end %>
<% end %>
<% end %>
<%= link_to 'ShopCliq', root_path, :class => "logo" %>
<% end %>
<!--MENU-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment