Reputation: 25328
I've got the following block:
#control-panel
%h3
= "Manage"
%ul.left-panel
%li{:class => 'my-profile'}
= link_to 'Profile', edit_user_path(current_user)
%li{:class => 'my-account'}
= link_to 'Account', edit_account_user_path(current_user)
-if @user && current_user.parent?
%li{:class => 'my-blog'}
= link_to 'Blog', manage_user_posts_path(current_user)
The problem is the if conditional on that last list item...doing it like that renders a closed </ul>
tag and then another list item. What I need is for that last list item to be a part of the unordered list if it meets the conditional.
How do I do that?
Upvotes: 0
Views: 3179
Reputation: 11460
Indent the -if and subsequent %li so they are in the same column as the %li elements above.
%ul.left-panel
%li{:class => 'my-profile'}
= link_to 'Profile', edit_user_path(current_user)
%li{:class => 'my-account'}
= link_to 'Account', edit_account_user_path(current_user)
-if @user && current_user.parent?
%li{:class => 'my-blog'}
= link_to 'Blog', manage_user_posts_path(current_user)
Also, just looking at your code, I'm guessing that the visitor is already a @user, if they can access the Profile and Account links, so the if @user may be redundant?
Upvotes: 2