I apologize if this does not meet the good recommendations, but I hope this is good in the class with How to manage CSS hacking and gets a similarly useful answer.
I am familiar with some basic adjacency mitigation strategies, such as:
- Use helpers if necessary
- Do not repeat yourself
- Use partial and layouts
Feel free to suggest something if I miss any big ideas in the list above.
However, I still get several dimensions / degrees of freedom, in my opinion, causing a lot of if-then statements, or at least three-dimensional blocks. For example, in something that I am facing right now, I am working on a title bar for a program where a view is called when three "big" variables are called:
- Admin user
- Is the user logging in
- Regardless of whether the page is being viewed by the user or someone else.
In the end, it looks like this mess:
<% content_for :subheader do %>
<div class="row">
<% if @user %>
<% if @user == current_user %>
<%= link_to 'My programs', user_programs_path(current_user), :class => 'active' %>
<% else %>
<%= link_to "#{@user.username} programs", user_programs_path(@user), :class => 'active' %>
<% end %>
<%= link_to 'Browse all programs', programs_path %>
<% else %>
<% if current_user %>
<%= link_to 'My programs', user_programs_path(current_user) %>
<% end %>
<%= link_to 'Browse all programs', programs_path, :class => 'active' %>
<% end %>
<%= link_to 'New Program', new_program_path, :class => 'admin' if current_user.admin? %>
</div>
<% if @regions %>
<div class="row second">
<%= link_to 'Regional program search', request.fullpath, :class => 'active' %>
</div>
<% end %>
<% end %>
Nasty. Readability and easy accessibility, but ugly. Some suggestions?
Between experience and new technologies, such as LESS , I have become very good for losing weight on my CSS files, but I still encounter problems related to the explosion with my MVC views.